[help on y_commands.inc]player permissions and commands with multiple parameters
#1

First Question: (Regarding multiple parameters)
For example a command such as this:,
Код:
/vehicle [id] [color1] [color2]
It consists of more then one parameter, where as y_commands just take parameters string array, so how can I split the string into multiple parameters ?
It will just take as:
pawn Код:
YCMD:vehicle (playerid, params[],help)
Its just taking one parameter. I have to use strtok or what? Is there any other way?



Second question: (regarding player permissions)
I did not understand the player permissions thing on y_commands, is there any tutorial available on this? How can I implement player permissions ? Is there any simple example available ?




Note: I do not know any other info about other includes , I am new in scripting pawno (not in scripting), someone informed me, y_commands is fastest and easiest command processor so I would like to learn this.
Reply
#2

Код HTML:
YCMD:vehicle(playerid, params[])
{
    if(!IsPlayerAdmin(playerid) && GetPVarInt(playerid, "Admin") < 2) return SendClientMessage(playerid,RED,"You are not RCON or Head admin!");
    else
    {
        new vehid;new b1;new b2;
        if(sscanf(params, "iii", vehid,b1,b2)) SendClientMessage(playerid, RED, "Use: /vehicle [car id] [color 1] [color 2]");
        else if(vehid < 400 || vehid > 611) return SendClientMessage(playerid, RED, "Wrong car id!");
        else if(vehid == 425 || vehid == 520 || vehid == 537 || vehid == 538 || vehid == 569 || vehid == 570 || vehid == 590) return SendClientMessage(playerid, CRVENA, "You can't spawn a hydra and the rest military vehicles!");
        else if(b2 <=0 || b2 >= 252) return SendClientMessage(playerid, RED, "Invalid color 1 id!");
        else if(b1 <=0 || b1 >= 252) return SendClientMessage(playerid, RED, "Invalid color 2 id!");
        else
        {
            new Float:x, Float:y, Float:z;new Float:fa;
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, fa);
            CreateVehicle(vehid, x + 3, y + 1, z, fa, b1, b2, -1);
            SendClientMessage(playerid, GREEN, "You have spawned a vehicle");
        }
    }
    return 1;
}
Reply
#3

Thanks, just few more questions, (very basic)


regarding, sscanf(params, "iii", vehid,b1,b2)
iii = integer integer integer ? I can also add/decrease parameters and use sscanf for the same?

Is this sscanf 2.0 or 1.0 ? Do we need to inlcude <sscanf> necessarily or its already inbuilt in pawno compiler, if its inbuilt (i saw it is), then what version does it use (the one with samp 0.3e) is it 2.0 ?
Reply
#4

This is the new sscanf 2.8.1: https://sampforum.blast.hk/showthread.php?tid=120356 ,and yes you need sscanf Include and plugin,
Read the sscanf topic to know more about sscanf
Reply
#5

Thanks a dozen for redirecting me to that topic. I found some better ways,
Код:
sscanf(params, "iii", vehid,b1,b2)
can be replaced as:
Код:
extract params -> new vehid,b1,b2;
sscanf is an amazing thing, read the full topic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)