DCMD using more than one param? -
Mikibey - 13.06.2012
Hello,long time no see,i've advanced a lot in coding from last time,and now i have another problem.
I cannot find a way to make a command ask for more than the player id...
Example:
/setfaction [playerid][factionid]
i can only make a kill command...like this one...
Код:
dcmd_setfaction(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel] < gCommands[SETFACTION])
{
new string[100];
format(string, sizeof(string), "You must be administrator level %d to use that command!", gCommands[SETFACTION]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else if(!strlen(params))
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /kill [id | name]");
else
{
new id = (isNumeric(params)) ? strval(params) : GetPlayerId(params);
if(IsPlayerConnected(id) && id != playerid)
{
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You can not admin-kill yourself or a disconnected player.");
}
}
//credits to wiki
can you please give me an example of how to ask for the player to type more than just the id?
Re: DCMD using more than one param? -
park4bmx - 13.06.2012
pawn Код:
dcmd_example(playerid, params[])
{
//now to make more then 1 params is simple, the easiest way is like this
new otherplayerid = params[0];//the id of the target player
new something = params[1];//variable for something i dont know its an example ;)
new text[250] = params[2];//string for player to type text etc.
//then later on you just use them like this
new str[128];format(str,sizeof(str),"player ID Selected %d, Something: %d, the text: %s",otherplayerid,something,text);
//and thats how you use them ;)
}
there is a sceond way
is the same thing but saves lines
pawn Код:
dcmd_example(playerid, params[])
{
//you dont have to add the new playerid, etc...
new str[128];format(str,sizeof(str),"player ID Selected %d, Something: %d, the text: %s",params[0],params[1],params[2]);
//and thats how you use them ;)
}
Re: DCMD using more than one param? -
Mikibey - 13.06.2012
Can you be a little more acurate please?bc i didnt uderstanded i mean,how do i use them to make something like
/command "Playerid" "value to change"
Please?
EDIT:Thanks for helping me,i finded out something intresting on the wiki:
https://sampwiki.blast.hk/wiki/Fast_Commands
Ty again
Re: DCMD using more than one param? -
park4bmx - 13.06.2012
pawn Код:
dcmd_command (playerid, params[])
{
if(Strlen(parmas[0])==0) return SendClinetMessage(playerid ,-1,"You need to enter the playerid");
if(Strlen(parmas[1])==0) return SendClinetMessage(playerid ,-1,"You need to enter a value");
}
params[0] is used for
playerid
params[1] is used for
value you want to change
Re: DCMD using more than one param? -
eSPeZet - 01.08.2017
I also would like to know that as I did not understand the explanation seen in the second post.
I want to create more parameters for a command with dcmd WITHOUT using sscanf and ONLY dcmd.
Could anybody show me that as an example with /givecash ID amount?
Thanks in advance
Re: DCMD using more than one param? -
eSPeZet - 02.08.2017
Is it impossible or does no one know? :/