cmds with id - 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)
+--- Thread: cmds with id (
/showthread.php?tid=346499)
cmds with id -
thefatshizms - 28.05.2012
Hi guys I can never get my head around how to make a command with I D could someone explain to me how I can do this and maybe present a code as an example with comments explaing aswell thanks
P.s sent from phone slow response -_-
Re: cmds with id -
juraska - 28.05.2012
Perhaps you mean commands with parameters?
Re: cmds with id -
thefatshizms - 28.05.2012
Yeh I think so :/ (I'm not sure what parameters are but I think I know) for e.g
/kick (Id)
/ban (Id)
/goto (Id)
Etc etc at the moment I can only do commands acting on the person who did the command
Re: cmds with id -
iGetty - 28.05.2012
With "sscanf"? you mean?
Re: cmds with id -
thefatshizms - 28.05.2012
Yeh I use sscanf2 I've seen codes with the (Id) but I can never get my head around how to do this D: so I was hoping for someone to explain how to do it what each line does etc etc
Re: cmds with id -
juraska - 28.05.2012
Код:
CMD:kick(playerid,params[])
{
// params is text input after your command ( in this case 'kick')
new id;// creating variable in which we will store the id of player /kick [id] in other param[0]
if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"Error: syntax - /kick [id]"); // checking does sscanf found integer parameter
Kick(id);// kick selected id
}
Re: cmds with id -
thefatshizms - 28.05.2012
Ahh I get it now I think xDD thanks a lot man this helped a lot ill post again tomoz when I get on pc to see if I fully understand and make myself a ban or something
Re: cmds with id -
juraska - 28.05.2012
you're welcome
ask if have any more questions
Re: cmds with id -
thefatshizms - 28.05.2012
Ok thanks

have a question

if I say wanted to make a command to do /givewep (wepid/name) (Id)
How would I do it? I would know how to do the Id part thanks to you

but I would have no clue for this
Re: cmds with id -
juraska - 28.05.2012
basically you need add additional variable and param to sscanf function.
just like this
Код:
CMD:kick(playerid,params[])
{
// params is text input after your command ( in this case 'kick')
new id;// creating variable in which we will store the id of player /kick [id] in other param[0]
new anotherid;// creating another variables in which we will store data of param
// now add to sscanf one more "i" - integer. and of course in third sscanf parameter our variable name 'anotherid'
if(sscanf(params,"ii",id,anotherid)) return SendClientMessage(playerid,-1,"Error: syntax - /kick [id]"); // checking does sscanf found integer parameter
Kick(id);// kick selected id
}
everything pretty much same