SA-MP Forums Archive
Params - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Params (/showthread.php?tid=121221)



Params - Devine - 16.01.2010

I plan on switching all my commands over to zcmd, but I just one little question.. what exatly are params? Like; Command_buyvehicle(playerid,params[]) Can someone define params? I don't understand exactly what they are and how they're used. Thanks!


Re: Params - Babul - 16.01.2010

the params[] consists the string (text) after your command - if you type:
/buyvehicle sultan 1 1
then the params[] will be "sultan 1 1", and that can be parsed with f.ex. sscanf inside your command to split it into the name, and the 2 colors.
coz iam too lazy now, heres a heal command:
Код:
new id,health;
if (sscanf(params,"ui",id,health))
{
	SendClientMessage(playerid,MSGCOMM_COLOR, "Usage: \"/Heal <PlayerID / Name> <Percentage (1-100)>\"");
}
else if(id==INVALID_PLAYER_ID)
{
	new string[256];
	format(string,sizeof(string),"Player [%d] not found",id);
	SendClientMessage(playerid,MSGFAIL_COLOR,string);
}
else
{						//here the parameters are ok, and are processed
	SetPlayerHealth(id, health);
	new Name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,Name,sizeof(Name));
	new string[256];
	format(string,sizeof(string),"[%d] %s healed you to %d\%",playerid,Name,health);
	SendClientMessage(id,MSGSUCC_COLOR,string);
	GetPlayerName(id,Name,sizeof(Name));
	format(string,sizeof(string),"You healed [%d] %s to %d percent\"",id,Name,health);
	SendClientMessage(playerid,MSGSUCC_COLOR,string);
}