SA-MP Forums Archive
Command only appears for ID 0 - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command only appears for ID 0 (/showthread.php?tid=78934)



Command only appears for ID 0 - Jakku - 24.05.2009

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?


Re: Command only appears for ID 0 - member - 24.05.2009

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.


Re: Command only appears for ID 0 - Weirdosport - 24.05.2009

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


Re: Command only appears for ID 0 - member - 24.05.2009

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.


Re: Command only appears for ID 0 - Jakku - 24.05.2009

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.