SA-MP Forums Archive
CMD problem - 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: CMD problem (/showthread.php?tid=661806)



CMD problem - KamilPolska - 15.12.2018

How to do as, for example, enter /giverank 0 2.
Example rank:
Number 1 - pInfo[playerid][pMod] = 1;
Number 2 - pInfo[playerid][pAdmin] = 1;

Код:
CMD:giverank(playerid, params[])
{
    if(pInfo[playerid][pAdmin] == 1)
    {
        new string[128], giveplayerid, rank;

        if(sscanf(params, "ud", giveplayerid, rank)) return SendClientMessage(playerid, -1, "USAGE: /giverank [playerid] [Rank (1-2)]");

        if(rank > 6 || rank < 0) { SendClientMessage(playerid, -1, "Don't go below number 0, or above number 6!"); return 1; }

        if(IsPlayerConnected(giveplayerid))
        {
            pInfo[giveplayerid][pAdmin] = rank;
            SendClientMessage(giveplayerid, -1, string);
            format(string, sizeof(string), "You have given %s rank %d.", PlayerName(giveplayerid), rank);
            SendClientMessage(playerid, -1, string);
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not authorized to use that command!");
    }
    return 1;
}



Re: CMD problem - TheToretto - 15.12.2018

Use strcmp for that.


Re: CMD problem - KamilPolska - 15.12.2018

Yes, but there will be an error because it is `new rank[16]` and not `new rank`.
Код:
if(rank > 6 || rank < 0) { SendClientMessage(playerid, -1, "Don't go below number 0, or above number 6!"); return 1; }



Re: CMD problem - d1git - 15.12.2018

PHP код:
if (rank == 1pInfo[giveplayerid][pMod] = 1;
else if (
rank == 2pInfo[playerid][pAdmin] = 1
Or just use a switch statement.


Re: CMD problem - KamilPolska - 16.12.2018

//del


Re: CMD problem - Threshold - 16.12.2018

PHP код:
CMD:giverank(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1"You are not authorized to use that command!");
    new 
giveplayeridrank;
    if(
sscanf(params"ud"giveplayeridrank)) return SendClientMessage(playerid, -1"USAGE: /giverank [playerid] [Rank (1-2)]");
    if(!
IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1"There is no such player!");
    switch(
rank)
    {
        case 
1pInfo[giveplayerid][pMod] = 1;
        case 
2..6pInfo[giveplayerid][pAdmin] = rank 1;
        default: 
SendClientMessage(playerid, -1"Don't go below number 0, or above number 6!");
    }
    return 
1;

'rank' is not a string or array in this instance, so it doesn't need you to specify a size. It is an integer and can be a standalone variable.

I'm assuming pAdmin is increased when a number above 1 is entered, so this is the code I've given you. Please change accordingly.


Re: CMD problem - KamilPolska - 16.12.2018

Okay. I will need it. Thanks!

How to write CMD [/giverank [id] [rank]] /giverank 0 5 is how to make it a message that there is no such rank.

Код:
if(strcmp(rank, "1", true) == 0)
else if(strcmp(rank, "2", true) == 0)
else if(strcmp(rank, "3", true) == 0)



Re: CMD problem - Threshold - 16.12.2018

I literally just gave you the code... just change the 'switch' statement values.
PHP код:
case 
Means rank = 1.
PHP код:
case 2..6 
Means rank = 2, 3, 4, 5 or 6.
PHP код:
default 
Means rank = something else

If you want it to be up to 5, just change 2..6 to 2..5


Re: CMD problem - KamilPolska - 16.12.2018

Thanks!