multi parameters?
#1

I need 2 commands that will have multi parameters(?) but I am lost and don't know where to start


First command would be an animation command. Instead of having two different commands, I'd like one command with multiple options; /reload [1-2] etc.
Код:
    
    else if(strcmp(cmdtext, "/reload", true) == 0)
	{
	    ApplyAnimation(playerid, "SILENCED", "Silence_reload", 3.0, 0, 0, 0, 0, 0);
	    return 1;
    }
    else if(strcmp(cmdtext, "/reload2", true) == 0)
	{
	    ApplyAnimation(playerid, "RIFLE", "RIFLE_load", 3.0, 0, 0, 0, 0, 0);
	    return 1;
    }
Second command would be a teleport command. Allowing me to use 'goto' and entering the pos. name to teleport there. E.G: /goto SF, /goto LS, /goto LV... etc.

Код:
CMD:goto(playerid, params[])
{
	SetPlayerPos(playerid, -1855.73853, -1692.89526, 42.66900);
	return 1;
}
Reply
#2

Hello.
Use zcmd & sscanf2. This is better and faster than "OnPlayerText".
When you have download those. Your command should be:
PHP код:
CMD:goto(playeridparams[])
{
    new 
place[6];
    if(
sscanf(params"s[5]"place)) return SendClientMessage(playerid, -1"[USE] /goto [SF/LV/LS]");
     
/*
     - If the player doesn't add any parameters so we send a message to show what parameter is waiting (here we use return to end the command).
     */
    
if(!strcmp(place"SF")) // We compare two strings : place (should be SF here) and "SF". If both strings are the same ("!") so we execute the code.
    
{
        
//Set the positions for SF
        
return 1// return 1 to end the command. 1 mean the command didn't fail
    
}
    if(!
strcmp(place"LS")) // We compare two strings : place (should be LS here) and "LS". If both strings are the same ("!") so we execute the code.
    
{
        
//Set the pos for LS
        
return 1;
    }
    if(!
strcmp(place"LV")) // We compare two strings : place (should be LV here) and "LV". If both strings are the same ("!") so we execute the code.
    
{
        
//Set the pos for LV
        
return 1;
    }
    else return 
SendClientMessage(playerid, -1"This place doesn't exist"); // If the player put a parameter which is not SF/LV/LS so return an error message and the command end here.
    //SetPlayerPos(playerid, -1855.73853, -1692.89526, 42.66900); I didn't delete this but you have to move it.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)