/FAKECMD isnt working
#1

the parameters of the cmd is /fakecmd [player id] [cmd] , when i do it sends a msg to the adminstrator that the fake command is sent , however nothing happens , i use zcmd (CMD) in all the commands i have in my gamemode , here's the code
Код:
CMD:fakecmd(playerid,params[])
{
	if(!IsPlayerAnAdmin(playerid,5))return SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
    new string2[128],command[128],string3[128];
    new pID, SpielerName[MAX_PLAYER_NAME];
    GetPlayerName(pID, SpielerName, sizeof(SpielerName));
    if(sscanf(params, "us", pID,string2)) return SendClientMessage(playerid, COLOR_GREEN, "/fakecmd [id] [command]");
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "The fakecommand has been send.");
    format(command,sizeof(command),"%s",string2);
    for(new i=0;i<GetMaxPlayers();i++)
	{
	if(IsPlayerConnected(i))
	{
	if(IsPlayerAnAdmin(i,1))
	{
    format(string3,sizeof(string3),"A: %s [LEVEL %i] used the FAKECMD command.",PlayerName(playerid),GetPVarInt(playerid,"Admin"));
	SendClientMessage(i,COLOR_ORANGE,string3);
	}
	}
	}
    OnPlayerCommandText(pID,command);
    return 1;
}
Thanks
Reply
#2

Код:
for(new i=0;i<GetMaxPlayers();i++)
should be

Код:
for(new i=0;i<=GetMaxPlayers();i++)
Код:
 format(string3,sizeof(string3),"A: %s [LEVEL %i] used the FAKECMD command.",PlayerName(playerid),GetPVarInt(playerid,"Admin"));
You don't need that inside the loop. Move it outside the loop. Why simply waste CPU calculating the same thing again and again?

As far as my knowledge goes, your code should work.

Add a printf just before calling OnPlayerCommandText and find out what are the contents of pID and command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)