Command only appears for ID 0
#1

I have following command in my reallife script:

Код:
	}
     if(strcmp(cmd, "/setmember", true) == 0) {
     new playername[MAX_PLAYERS];
     new ID = strval(cmdtext[6]);
     new pName[24];
     GetPlayerName(ID, pName, 24);
     GetPlayerName(playerid, playername, sizeof(playername));
     format(string, sizeof(string), "%s has set you member of his organization!", playername);
     SendClientMessage(ID, COLOR_YELLOW, string);
     return 1;
	}
When I do /setmember 1, text appears always for id 0. I need to appear it ID I enter like /setmember 1. What is the problem?
Reply
#2

pawn Код:
if(strcmp(cmd, "/setmember", true, 10))
         {
            if(!strlen(cmdtext[10])) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setmember [playerid]");
            new playername[MAX_PLAYER_NAME], myname[MAX_PLAYER_NAME];
            new ID = strval(cmdtext[11]);
            if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_YELLOW, "That player isnt connected!");
            GetPlayerName(ID, playername, sizeof(playername));
            GetPlayerName(playerid, myname, sizeof(myname));
            format(string, sizeof(string), "Hi %s , %s has set you member of his organization!", playername, myname);
            SendClientMessage(ID, COLOR_YELLOW, string);
            return 1;
        }
Not tested. You need to specify the length of "/setmember"and also where "ID" is from.
Reply
#3

Surely cmdtext[11] is just 1 of the numbers, what if you wanted to do it to id 35?
Reply
#4

Quote:
Originally Posted by Weirdosport
Surely cmdtext[11] is just 1 of the numbers, what if you wanted to do it to id 35?
From what i know, the "ID" value will be from cmdtext 11 onwards, so it shouldn't count only the first number. It has worked for me before for my commands.
Reply
#5

Quote:
Originally Posted by [B2K
Hustler ]
pawn Код:
if(strcmp(cmd, "/setmember", true, 10))
         {
            if(!strlen(cmdtext[10])) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setmember [playerid]");
            new playername[MAX_PLAYER_NAME], myname[MAX_PLAYER_NAME];
            new ID = strval(cmdtext[11]);
            if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_YELLOW, "That player isnt connected!");
            GetPlayerName(ID, playername, sizeof(playername));
            GetPlayerName(playerid, myname, sizeof(myname));
            format(string, sizeof(string), "Hi %s , %s has set you member of his organization!", playername, myname);
            SendClientMessage(ID, COLOR_YELLOW, string);
            return 1;
        }
Not tested. You need to specify the length of "/setmember"and also where "ID" is from.
I tried what, worked but when other player used jobsystem like /job 1, it appeared USAGE: /kickmember [playerid] and some other cmds too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)