Reading Cmds Problem. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Reading Cmds Problem. (
/showthread.php?tid=523012)
Reading Cmds Problem. -
FedEx - 30.06.2014
Hello all...
Have one problem idk what to do...
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new idx;
new i;
new playername[MAX_PLAYER_NAME];
string = strtok(cmdtext, idx);
if(ServerInfo[ReadCmds] == 1)
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "*** %s (%d) typed: %s", playername,playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++) //THIS LINE IS THE PROBLEM...
if(IsPlayerConnected(i))
if( (PlayerInfo[i][Level] > PlayerInfo[playerid][Level]) && (PlayerInfo[i][Level] > 1) && (i != playerid) )
IRC_GroupSay(gGroupID3, IRC_MCHANNEL, string);
SendClientMessage(i, grey, string);
It just doesn't show when someone type any wrong cmd...how to fix it?
Thanks.
Re: Reading Cmds Problem. -
Twizted - 30.06.2014
That's not how a loop works. You might want to try the following and see if it works. Pay attention to the comments.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new idx;
new i;
new playername[MAX_PLAYER_NAME];
string = strtok(cmdtext, idx);
if(ServerInfo[ReadCmds] == 1)
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "*** %s (%d) typed: %s", playername,playerid,cmdtext);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) //then do what?
if( (PlayerInfo[i][Level] > PlayerInfo[playerid][Level]) && (PlayerInfo[i][Level] > 1) && (i != playerid) ) //then do what?
IRC_GroupSay(gGroupID3, IRC_MCHANNEL, string);
SendClientMessage(i, grey, string);
return 1;
}
return 1;
}