dcmd_givecash IS working but sending wrong messages
#1

Hello! My givecash command worked fine, but I replaced SystemMessage by SendClientMessage because I wanted to change colour. The command is still working but sending the wrong messages. Here is my command. What is wrong?

Код:
dcmd_givecash(playerid, params[])
{
	new amount, str[128];
	if(sscanf(params, "ud", giveplayerid, amount)) return SystemMessage(playerid, "USAGE: /givecash [playername/id] [amount]");
	if(!IsPlayerConnected(giveplayerid) || giveplayerid == playerid) return SystemMessage(playerid, "This player is not active.");
	if(amount < 1 || amount > GetPlayerMoney(playerid)) return SystemMessage(playerid, "Invalid amount.");
	GetName(playerid, playername);
	GetName(giveplayerid, giveplayer);
	GivePlayerMoney(playerid, -amount);
	GivePlayerMoney(giveplayerid, amount);
	format(str, sizeof(str), "You have given $%d to %s.", amount, giveplayer);
	SendClientMessage(playerid, COLOR_GREEN, str);
	format(str, sizeof(str), "%s has given you $%d.", playername, amount);
	SendClientMessage(playerid, COLOR_GREEN, str);
	return 1;
}
Reply
#2

what does it send, and what do u want to be send?
Reply
#3

pawn Код:
dcmd_givecash(playerid, params[])
{
    new amount, str[128];
    if(sscanf(params, "ud", giveplayerid, amount)) return SystemMessage(playerid, "USAGE: /givecash [playername/id] [amount]");
    if(!IsPlayerConnected(giveplayerid) || giveplayerid == playerid) return SystemMessage(playerid, "This player is not active.");
    if(amount < 1 || amount > GetPlayerMoney(playerid)) return SystemMessage(playerid, "Invalid amount.");
    GetName(playerid, playername);
    GetName(giveplayerid, giveplayer);
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    format(str, sizeof(str), "You have given $%d to %s.", amount, giveplayer);
    SendClientMessage(playerid, COLOR_GREEN, str);
    format(str, sizeof(str), "%s has given you $%d.", playername, amount);
    SendClientMessage(giveplayer, COLOR_GREEN, str); // -----------------
    return 1;
}
________
Yamaha mm6 specifications
Reply
#4

Quote:

but I replaced SystemMessage by SendClientMessage because I wanted to change colour

Why you do that? xD Just change the color in your script

Quote:

dcmd_givecash(playerid, params[])
{
// bla bla
SendClientMessage(playerid, COLOR_GREEN, str);
return 1;
}

Into:

Quote:

dcmd_givecash(playerid, params[])
{
// bla bla
SendClientMessage(playerid, YOUR COLOR, str);
return 1;
}

Reply
#5

I replaced SystemMessage by SendClientMessage
i think he got an new stock 'SystemMessage' and he replaced that with SendClientMessage
Reply
#6

Код:
//------------------------------[GiveCash]---------------------------------------------------------------
dcmd_givecash(playerid, params[])
{
  new string[256];
  new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount))return SendClientMessage(playerid, 0xFF9900AA, "Usage: /givecash [Playerid/Partname] [Amount]");
	else if (giveplayerid == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF9900AA, "Player Is Not Connected");
	else if (amount > GetPlayerMoney(playerid))return SendClientMessage(playerid, 0xFF9900AA, "You Don't Have Enough Money!");
	else if (giveplayerid == playerid)return SendClientMessage(playerid,0xFF9900AA,"You Can't Give Money To Yourself!");
    else
	{
		GivePlayerMoney(giveplayerid, amount);
		GameTextForPlayer(giveplayerid,"~g~Money Recived",3000,5);
		format(string, sizeof(string), "You Recived $%d From Player %s(%d)",amount,playername,giveplayerid);
		SendClientMessage(giveplayerid,0x33CCFFAA,string);

		GivePlayerMoney(playerid, 0 - amount);
		GameTextForPlayer(playerid,"~y~Money Sent",3000,5);
		format(string, sizeof(string), "You Have Sent $%d To Player %s(%d)",amount,playername,playerid);
		SendClientMessage(playerid,0x33CCFFAA,string);
	}
	return 1;
}
Reply
#7

You have str twice in the command.
Reply
#8

Quote:
Originally Posted by Hijolion
Посмотреть сообщение
You have str twice in the command.
what he said,
if you use same string for 2 msgs, it will be bugged.
Reply
#9

Quote:
Originally Posted by HuRRiCaNe
Посмотреть сообщение
what he said,
if you use same string for 2 msgs, it will be bugged.
You just Don't Know How To Use it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)