Need help with this command
#1

Hello!

I have a problem with /warn command. When i type id it put warn on id 0 not the id which i type
Код:
if(strcmp(cmd,"/awarn", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 6)
{
new targetid, reason[100];
if(IsPlayerConnected(targetid))
{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
      SendClientMessage(playerid, COLOR_GRAD2, "{00FF00}Използвай:{FFFFFF} /awarn [playerid/име] [reason]");
      return 1;
    }
if(targetid != INVALID_PLAYER_ID)
{
if(PlayerInfo[targetid][pWarns] == 3)
{
new msg[300], tname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], string[128];
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "SERVER: {FF0000}%s(ID: %d) {FF00FF}беше кикнат, Причина: {FF0000}warning 3/3", tname, targetid);
SendClientMessageToAll(-1, msg);
format(string, sizeof(string), "%s беше кикнат от сървъра. Причина: warning 3/3", tname);
Kick(targetid);
}
if(PlayerInfo[targetid][pWarns] < 3)
{
new msg[300], tname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], string[128];
PlayerInfo[targetid][pWarns]++;
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "ADMIN_WARN: {FF0000}%s {FF00FF}беше предуреден, Reason: {FF0000}%s{FF00FF}, предупреждания: {FF0000}%d/3", tname, reason, PlayerInfo[targetid][pWarns]);
SendClientMessageToAll(-1, msg);
format(string, sizeof(string), "%s беше предуреден от %s, Reason: %s", tname, name, reason);
}
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: няма такова ID");
}
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: Ти трябва да си поне админ 6+.");
return 1;
}
Here is the command
Reply
#2

You should REALLY use a command processor.

And probably because you're checking if the targetid is connected before establishing the param that would select the targetid.

PHP код:
new targetidreason[100];
if(
IsPlayerConnected(targetid))
{
    
tmp strtok(cmdtextidx);
    if(!
strlen(tmp))
    {
      
SendClientMessage(playeridCOLOR_GRAD2"{00FF00}Използвай:{FFFFFF} /awarn [playerid/име] [reason]");
      return 
1;
    } 
Reply
#3

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
You should REALLY use a command processor.

And probably because you're checking if the targetid is connected before establishing the param that would select the targetid.

PHP код:
new targetidreason[100];
if(
IsPlayerConnected(targetid))
{
    
tmp strtok(cmdtextidx);
    if(!
strlen(tmp))
    {
      
SendClientMessage(playeridCOLOR_GRAD2"{00FF00}Използвай:{FFFFFF} /awarn [playerid/име] [reason]");
      return 
1;
    } 
Can you help me fix it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)