[Help] /SetRank Command (like admins)
#1

How can i make it where i type in a command, and i can set another players rank in a buisness?


Command:
if (strcmp("/S25SetRank", cmdtext, true) == 0)

Rank:
S25TRank[playerid]
Reply
#2

You can do this by using sscanf2. Here is a tutorial about it. https://sampforum.blast.hk/showthread.php?tid=232129
Reply
#3

Thankyou


For anyone else, this is an example from ZCMD, one of the 2 includes you need with the link Mystique posted.



Код:
COMMAND:givemoney(playerid, params[])
{
    if (IsPlayerAdmin(playerid))
    {
        new
          toplayerid, // the player we want to give money to
          amount;
        // extracting player's ID and amount from params
        if (!sscanf(params, "ii", toplayerid, amount))
        {
          if (toplayerid != INVALID_PLAYER_ID)
          {
            new
              message[40];
            GivePlayerMoney(toplayerid, amount);
            format(message, sizeof(message), "You got $%d from admin!", amount);
            SendClientMessage(toplayerid, 0x00FF00FF, message);
          }
          else SendClientMessage(playerid, 0xFF0000FF, "That player is not connected");
        }
        else SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /givemoney <playerid> <amount>");
    }
    else SendClientMessage(playerid, 0xFF0000FF, "Only admins can use this command!");
    return 1;
}
Reply
#4

Код:
if(strcmp("/SetRank",cmdtext,true)==0){
   if(AdminLevelVarThatYouHave[playerid] >= #oflevelthatyouwant)// well if you'd to make this an admin cmd do that
new idx;
new tmp[256];
new tmp2[256]; 
tmp = strtok(cmdtext,idx);
tmp2 = strtok(cmdtext,idx);
 if(!strlen(tmp) !strlen(tmp2)) return SendClientMessage(playerid,0xFF0000AA,"USE: /SetRank [id] [rank]");//
new id = strval(tmp);//that replace tmp for a new code
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000AA,"Player is not online");
if(Rank[id] == tmp2) return SendClientMessage(playerid,0xFF0000AA,"Player is already with that rank");
new ranklevel = strval(tmp2);
Rank[id] = ranklevel;
new string[256],new name[256];
GetPlayerName(playerid,name,256);
format(string,256,"Admin %s has set you rank to %d",name,tmp2);
SendClientMessage(playerid,oxFF0000AA,string);
}
else 
{
return SendClientMessage(playerid,0xFF0000AA,"You need to be admin");
}
return 1;
// if i made a mistake please forgive me i'm learning pawno scripting :)
//if my english is so bad i'm sorry but i still learning 
// you should have strtok function in your scrip
// you should change variables because i don't know your's
// and that's it have fun 8)
}
Reply
#5

i don't quite understand that code or what to change. Its not working right for me.
Reply
#6

Post your code and tell me what's wrong with it.
Reply
#7

Command:

Код:
if(strcmp("/S25SetRank", cmdtext, true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(S25TRank[playerid] >= 4)
            {
                new idx;
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /S25SetRank [playerid/PartOfName] [level]");
                    return 1;
                }
                new para1;
                new level;
                new tmp[256];
                new giveplayer[MAX_PLAYER_NAME];
                para1 = ReturnUser(tmp);
                tmp = strtok(cmdtext, idx);
                level = strval(tmp);
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        PlayerInfo[para1][S25TRank] = level;
                        printf("	Filterscript: S25: %s promoted %s to level %d S25 worker.", sendername, giveplayer, level);
                        format(string, sizeof(string), "Server: You have been promoted to a level %d Stage 25 Worker by %s.", level, sendername);
                        SendClientMessage(para1, COLOR_SERVER, string);
                        format(string, sizeof(string), "Server: You have promoted %s to a level %d Stage 25 Worker.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_SERVER, string);
                    }
                }
            }
        }
        return 1;
    }


Error:

Код:
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1144) : error 017: undefined symbol "tmp"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1144) : error 017: undefined symbol "strtok"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1145) : error 017: undefined symbol "tmp"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1147) : error 017: undefined symbol "COLOR_GRAD2"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1154) : error 017: undefined symbol "ReturnUser"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1155) : error 017: undefined symbol "strtok"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1155) : error 033: array must be indexed (variable "tmp")
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1162) : error 017: undefined symbol "sendername"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1162) : error 017: undefined symbol "sendername"
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1162) : error 029: invalid expression, assumed zero
C:\Servers\SAMP\Testing Server\Programming\filterscripts\Stage_25_Towing_V0.pwn(1162) : fatal error 107: too many error messages on one line
I can fix the color error real quick.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)