cmds with id
#1

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 -_-
Reply
#2

Perhaps you mean commands with parameters?
Reply
#3

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
Reply
#4

With "sscanf"? you mean?
Reply
#5

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
Reply
#6

Код:
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
}
Reply
#7

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
Reply
#8

you're welcome
ask if have any more questions
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)