SendClientMessage
#1

Hello.. I got a command /setmoney, it sets the player money, but I can't get it working that it send me a message 'You have set ***'s money to *** and the person which I setted the money gets a message Admin *** has set your money to ***.

This is my code:
Код:
	if(strcmp(cmd, "/setmoney", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setmoney [playerid/PartOfName] [amount]");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setmoney [playerid/PartOfName] [amount]");
				return 1;
			}
			money = strvalEx(tmp);
			if(PlayerInfo[playerid][pAdmin] >= 4)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
			            GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						ResetPlayerMoney(playa);
						PlayerInfo[playa][pCash] = money;
						GivePlayerMoney(playa, money);
						format(string, sizeof(string), "You have setted %s's money to $%d.",PlayerName(giveplayerid), money);
						SendClientMessage(giveplayerid, COLOR_BLUE, string);
						format(string, sizeof(string), "Admin %s Has set your money to $%d.", PlayerName(playerid), money);
						SendClientMessage(playerid, COLOR_BLUE, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}
How do I fix it lol.
Reply
#2

Switch giveplayerid and playerid in the strings.
Reply
#3

Still not working, only get a message; Admin (nothing) has set your money to ****


Edit; Deleted my 2 NPC busdrivers, looks like it is working now!


Nope.. It's still not working, I got the 2 messages now, but one of them has to go to the reciever.. Not me.. How do I fix that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)