Help for 2 commands..
#1

I need this command applies to the actions of all players, not just one.

Код:
	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;
	}
Код:
	if(strcmp(cmd, "/givemoney", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givemoney [Playerid/PartOfName] [money]");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 1337)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
						GivePlayerCash(playa, money);
					}
				}
			}
		}
		return 1;
	}
Reply
#2

what do u mean by action of all players?
Reply
#3

I need to run the command for all players on the server, not the one.
Reply
#4

Use for loops https://sampwiki.blast.hk/wiki/Loops
Reply
#5

I don't understand this.Can you create the command for me?
Reply
#6

Please help!
Reply
#7

Please heeeeeeeeeeeeeeeeeeeeeeeelp!
Reply
#8

Try this, if there are any errors just tell me:

Код:
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)
		{
			for(new i = 0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(i != INVALID_PLAYER_ID)
					{
						PlayerInfo[i][pKills] += kills1;
						SetPlayerScore(i, PlayerInfo[playa][pKills]);
					}
				}
			}
		}
	}
	return 1;
}
Код:
if(strcmp(cmd, "/givemoney", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givemoney [Playerid/PartOfName] [money]");
			return 1;
		}
		new playa;
		new money;
		playa = ReturnUser(tmp);
		tmp = strtok(cmdtext, idx);
		money = strval(tmp);
		if (PlayerInfo[playerid][pAdmin] >= 1337)
		{
			for(new i = 0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(i != INVALID_PLAYER_ID)
					{
						GivePlayerCash(i, money);
					}
				}
			}
		}
	}
	return 1;
}
Reply
#9

Don't work.
Reply
#10

Try these out, if there is an error tell me. You should try using sscanf and zcmd to make it easier.


Код:
if(strcmp(cmd, "/givekill", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givekill [kills]");
			return 1;
		}
		
		new kills1;
		tmp = strtok(cmdtext, idx);
		kills1 = strval(tmp);
		if (PlayerInfo[playerid][pAdmin] == 1337)
		{
			for(new i = 0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(i != INVALID_PLAYER_ID)
					{
						PlayerInfo[i][pKills] += kills1;
						SetPlayerScore(i, PlayerInfo[playa][pKills]);
					}
				}
			}
		}
	}
	return 1;
}
Код:
if(strcmp(cmd, "/givemoney", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givemoney [money]");
			return 1;
		}
		
		new money;
		tmp = strtok(cmdtext, idx);
		money = strval(tmp);
		if (PlayerInfo[playerid][pAdmin] >= 1337)
		{
			for(new i = 0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if(i != INVALID_PLAYER_ID)
					{
						GivePlayerCash(i, money);
					}
				}
			}
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)