Give command dont work..
#1

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;
	}
Reply
#2

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
Reply
#3

You're confusing the variables/parameter cmd and cmdtext
Reply
#4

How to fix them?
Reply
#5

Help please?
Reply
#6

Код:
	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;
}
Reply
#7

Thank you very much, but givekill command dont work.. Setkill work perfectly.
Reply
#8

Help?
Reply
#9

Please help me man..
Reply
#10

You sure you are logged in as admin?
Код:
if(PlayerInfo[playerid][pAdmin] == 1337)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)