Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Script for Profile

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
DoranIsHere
Meatbag
Posts: 4
Joined: Mon Apr 11, 2016 8:16 pm

Script for Profile

Post by DoranIsHere » Sat Jul 16, 2016 11:27 pm

Hello, can someone give me a script that can change player profile(looking) when they spawn?
and can i do every player individual profile?

Thanks
-doran
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Thu Jul 21, 2016 1:00 am

DoranIsHere wrote:Hello, can someone give me a script that can change player profile(looking) when they spawn?
and can i do every player individual profile?

Thanks
-doran
Put in your map 8 profiles, change each ID from "profile1" to "profile8" then put even a timer trigger with 0 seconds of delay, activate on startup to true and set script method with "ProfileSelector".

Here the code:

Code: Select all

String[] IDlist={"profile1","profile2","profile3","profile4","profile5","profile6","profile7","profile8"};

public void ProfileSelector(TriggerArgs arg)
{
int i=0;
IUser check;
IPlayer[] players=Game.GetPlayers();
IObjectPlayerProfileInfo info;


foreach(IPlayer pl in players)
	{check=pl.GetUser();
		if(check!=null){
		info=(IObjectPlayerProfileInfo)Game.GetObjectsByCustomID(IDlist[i])[0];
		pl.SetProfile(info.GetProfile());
		i++;
		}
	}
}
1 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Tue Jul 26, 2016 12:35 pm

CrazyDUDE wrote:this is another one (this has to triggered, like when you push the button or somehting else, it will get the profile):

public void GetProfile(TriggerArgs args){
IPlayer ply = (IPlayer)args.Sender;
ply.SetProfile(((IObjectPlayerProfileInfo)
Game.GetFirstObject("Policiaa")).GetProfile());
}



or if it's for all the players...


public void GetProfile(TriggerArgs args){
foreach(IPlayer ply in Game.GetPlayers()){
ply.SetProfile(((IObjectPlayerProfileInfo)
Game.GetFirstObject("Policiaa")).GetProfile());
}
}





REMEMBER: IT HAS TO BE TRIGGERED, OR IF YOU WANT IT'S NOT NECESARY.
I need to make you see that you haven't specified the string "Policiaa" is a profile name (it is evident but if He don't know anything of programming the script will fail untill He correct that).

Also, as I understood, He needs a profile per player so the maximum number of player in a server (not the bots) is 8 and your script changes only to one profile and even the bot profile.
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Wed Jul 27, 2016 1:26 pm

CrazyDUDE wrote:well, he can do this:


public void OnStartup(){
foreach(IPlayer ply in Game.GetPlayers()){
ply.SetProfile(((IObjectPlayerProfileInfo)
Game.GetFirstObject("Policiaa")).GetProfile());
}
}



and that's all.

Added in 34 seconds:
"Policiaa" it's just an example of the profile ID

Ok but with this he has only one profile, and he said:
DoranIsHere wrote: can i do every player individual profile?
You need to make that each player have an unique profile and not all the same one.
I hope you understood now.
1 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Thu Jul 28, 2016 11:03 am

CrazyDUDE wrote:well, i didn't but I'll mean that yes.
but also where did you learned this script ?
Well, I'm studying Java programming at school and like c# is an object based programming language, so first of all I need to read the documentation of the API, is a list of methods created by Gurt or standar of the Box2D library and in a little time I was able to write these scripts.
0 x

jamisco
Superfighter
Superfighter
Posts: 67
Joined: Sun Nov 06, 2016 11:34 pm
Title: Da God
SFD Account: Jamisco
SFD Alias: Jamisco
Started SFD: either late 2015 or early 2016
Location: Somewhere in the east of the United states
Gender:
Age: 103

Post by jamisco » Sun Feb 19, 2017 9:33 pm

Here the code:

Code: Select all

String[] IDlist={"profile1","profile2","profile3","profile4","profile5","profile6","profile7","profile8"};

public void ProfileSelector(TriggerArgs arg)
{
int i=0;
IUser check;
IPlayer[] players=Game.GetPlayers();
IObjectPlayerProfileInfo info;


foreach(IPlayer pl in players)
	{check=pl.GetUser();
		if(check!=null){
		info=(IObjectPlayerProfileInfo)Game.GetObjectsByCustomID(IDlist[i])[0];
		pl.SetProfile(info.GetProfile());
		i++;
		}
	}
}
[/quote]



hey mr JakSpar, ive been examing some of your code lately inorder to learn and ive noticed you use this fail safe method like you did in this code line

if(check! = null) ... i understand its a fail safe but isn't it completely redundant because the method Game.GetPlayers() will only get players and not something null.. so if i may ask why do you still use it?
1 x
Is it better to be feared or respected... please, is it too much to ask for both?

User avatar
ShutDownMan
Fighter
Fighter
Posts: 32
Joined: Sat Mar 19, 2016 7:17 pm
Title: Yeah, science!
SFD Alias: ShutDownMan, Devil Shut
Started SFD: 1.2.something
Location: Hu3, Brazil
Gender:
Age: 24
Contact:

Post by ShutDownMan » Sun Feb 19, 2017 10:18 pm

jamisco wrote: hey mr JakSpar, ive been examing some of your code lately inorder to learn and ive noticed you use this fail safe method like you did in this code line

if(check! = null) ... i understand its a fail safe but isn't it completely redundant because the method Game.GetPlayers() will only get players and not something null.. so if i may ask why do you still use it?
The Game.GetPlayers() will return all players in game, PLAYERS, including bots... Bots don't have an IUser controlling them, so IPlayer.GetUser() can be null, that's why you need a failsafe for that
2 x
~ShutDownMan

Post Reply