Give command dont work.. -
dundolina - 25.11.2014
Why this 2 commands dont work?
Код:
if(strcmp(cmd, "/setkill", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setkill [Playerid/PartOfName] [kills]");
return 1;
}
new playa;
new kills1;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
kills1 = strval(tmp);
if (PlayerInfo[playerid][pAdmin] == 1337)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
PlayerInfo[playa][pKills] = kills1;
SetPlayerScore(playa, PlayerInfo[playa][pKills]);
}
}
}
}
return 1;
}
if(strcmp(cmd, "/givekill", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givekill [Playerid/PartOfName] [kills]");
return 1;
}
new playa;
new kills1;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
kills1 = strval(tmp);
if (PlayerInfo[playerid][pAdmin] == 1337)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
PlayerInfo[playa][pKills] += kills1;
SetPlayerScore(playa, PlayerInfo[playa][pKills]);
}
}
}
}
return 1;
}
Re : Give command dont work.. -
Dutheil - 25.11.2014
Why do you check if the player who writes the command is connected ?
pawn Код:
if(IsPlayerConnected(playerid))
And why do you check if the id is invalid after checking if the player is connected ?
pawn Код:
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
Use zcmd+sscanf
Re: Give command dont work.. -
DavidBilla - 25.11.2014
You're confusing the variables/parameter cmd and cmdtext
Re: Give command dont work.. -
dundolina - 25.11.2014
How to fix them?
Re: Give command dont work.. -
dundolina - 26.11.2014
Help please?
Re: Give command dont work.. -
Raweresh - 26.11.2014
Код:
if(strcmp(cmd,"/setkill",true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_WHITE,"USAGE: /setkill [Playerid/PartOfName] [kills]");
return 1;
}
new playa;
playa = ReturnUser(tmp);
tmp = strrest(cmdtext,idx);
if(IsPlayerConnected(playa))
{
PlayerInfo[playa][pKills] = strval(tmp);
SetPlayerScore(playa,PlayerInfo[playa][pKills]);
}
return 1;
}
if(strcmp(cmd,"/givekill",true) == 0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_WHITE,"USAGE: /givekill [Playerid/PartOfName] [kills]");
return 1;
}
new playa;
playa = ReturnUser(tmp);
tmp = strrest(cmdtext,idx);
if(PlayerInfo[playerid][pAdmin] == 1337)
{
if(IsPlayerConnected(playa))
{
PlayerInfo[playa][pKills] += strval(tmp);
SetPlayerScore(playa,PlayerInfo[playa][pKills]);
}
}
return 1;
}
Код:
stock strrest(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[128];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Re: Give command dont work.. -
dundolina - 26.11.2014
Thank you very much, but givekill command dont work.. Setkill work perfectly.
Re: Give command dont work.. -
dundolina - 26.11.2014
Help?
Re: Give command dont work.. -
dundolina - 26.11.2014
Please help me man..
Re: Give command dont work.. -
Raweresh - 26.11.2014
You sure you are logged in as admin?
Код:
if(PlayerInfo[playerid][pAdmin] == 1337)