How can i make this?
#1

Hi, I wonder how i can make that a command only works for a specific person or if i can make it work for only 3 persons?
Reply
#2

First you need to get a players name then to use it, heres an example
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(strcmp(name,"Don_Cage") || strcmp(name,"Don_Cage_One") || strcmp(name,"Don_Cage_Two") == 0)
{
      // YOUR COMMAND
Reply
#3

so if i want it to work for 3 persons i do like
pawn Код:
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(strcmp(name,"Don_Cage") || strcmp(name,"Don_Cage_One") || strcmp(name,"Other_Person_Two")  || strcmp(name,"One_More_Three")== 0)
is it like that?
Reply
#4

Quote:
Originally Posted by Don_Cage
Посмотреть сообщение
so if i want it to work for 3 persons i do like
pawn Код:
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(strcmp(name,"Don_Cage") || strcmp(name,"Don_Cage_One") || strcmp(name,"Other_Person_Two")  || strcmp(name,"One_More_Three")== 0)
is it like that?
4 players.
Reply
#5

yes. heres an sample zcmd command
pawn Код:
CMD:test(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(strcmp(name,"Don_Cage") || strcmp(name,"Don_Cage_One") || strcmp(name,"Other_Person_Two")  || strcmp(name,"One_More_Three")== 0)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "Yes. You can use the /test command");
    }
    else
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "No. You can't use the /test command");
    }
     return 1;
}
Reply
#6

so now can only Don_Cage Joe_Williams and Xander_Cage use this command right?
pawn Код:
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(strcmp(name,"Don_Cage") || strcmp(name,"Joe_Williams") || strcmp(name,"Xander_Cage") == 0)
    {
    if(strcmp(cmd, "/senate", true) == 0 || strcmp(cmd, "/sen", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You are NOT part of the Senate!");
                return 1;
            }
           
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/sen)ate [Criminal Senate Annouce]");
                return 1;
            }
                if(PlayerInfo[playerid][pRank] == 3) { format(string, sizeof(string), "[Criminal Senate]: Lead Senator (radio): %s, over.", sendername, result); }
                else if(PlayerInfo[playerid][pRank] == 2) { format(string, sizeof(string), "[Criminal Senate]: Senior Senator (radio): %s, over.", sendername, result); }
                else if(PlayerInfo[playerid][pRank] == 1) { format(string, sizeof(string), "[Criminal Senate]: Junior Senator (radio): %s, over.", sendername, result); }
                else
                {
                    format(string, sizeof(string), "[Unknown] [Criminal Senate] (radio): %s, over.", sendername, result);
                }
                ProxDetector(7.5, playerid, string,COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                SentMessage[playerid] = 1;
                SendRadioMessage(5 || 6 || 8 || 13 || 14 || 15 || 16 || 17 || 18, TEAM_RADIO_COLOR, string);
                SentMessage[playerid] = 0;
                new y, m, d;
                gettime(h,mi,s);
                format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) [Criminal Senate] (radio): (%s)",d,m,y,h,mi,s, sendername, result);
                RadioChatLog(string);
                return 1;
            }

        }
        return 1;
    }
but how can i make the set them as ''Lead Senator'' ''Senior Senator'' or ''Junior Senator'' ?
Reply
#7

i tryed to complie and got this errors
pawn Код:
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(53859) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(53860) : error 017: undefined symbol "result"
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(53867) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54161) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54173) : error 017: undefined symbol "h"
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54174) : error 017: undefined symbol "h"
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54180) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(57838) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(85413) : warning 219: local variable "name" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Reply
#8

pawn Код:
if(strcmp(cmd, "/senate", true) == 0 || strcmp(cmd, "/sen", true) == 0)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        if(strcmp(name,"Don_Cage") || strcmp(name,"Joe_Williams") || strcmp(name,"Xander_Cage") == 0)
        {
            if(IsPlayerConnected(playerid))
            {
                if(PlayerInfo[playerid][pMuted] == 1)
                {
                    SendClientMessage(playerid, TEAM_CYAN_COLOR, "You are NOT part of the Senate!");
                    return 1;
                }
               
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/sen)ate [Criminal Senate Annouce]");
                    return 1;
                }
                    if(PlayerInfo[playerid][pRank] == 3) { format(string, sizeof(string), "[Criminal Senate]: Lead Senator (radio): %s, over.", sendername, result); }
                    else if(PlayerInfo[playerid][pRank] == 2) { format(string, sizeof(string), "[Criminal Senate]: Senior Senator (radio): %s, over.", sendername, result); }
                    else if(PlayerInfo[playerid][pRank] == 1) { format(string, sizeof(string), "[Criminal Senate]: Junior Senator (radio): %s, over.", sendername, result); }
                    else
                    {
                        format(string, sizeof(string), "[Unknown] [Criminal Senate] (radio): %s, over.", sendername, result);
                    }
                    ProxDetector(7.5, playerid, string,COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    SentMessage[playerid] = 1;
                    SendRadioMessage(5 || 6 || 8 || 13 || 14 || 15 || 16 || 17 || 18, TEAM_RADIO_COLOR, string);
                    SentMessage[playerid] = 0;
                    new y, m, d;
                    gettime(h,mi,s);
                    format(string, sizeof(string), "[%d/%d/%d](%d:%d:%d) [Criminal Senate] (radio): (%s)",d,m,y,h,mi,s, sendername, result);
                    RadioChatLog(string);
                    return 1;
                }

            }
        }
        return 1;
    }
Reply
#9

fixed one error but dont understand where the others are
pawn Код:
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54155) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54167) : error 017: undefined symbol "h"
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54168) : error 017: undefined symbol "h"
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(54174) : warning 217: loose indentation
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(57832) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Users\new account\Desktop\Everything and Anything\Server\Script\gamemodes\mazda.pwn(85407) : warning 219: local variable "name" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#10

pawno crashes for some reason.. maybe you could help in team viewer if you have time?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)