SA-MP Forums Archive
dcmd_givecash IS working but sending wrong messages - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dcmd_givecash IS working but sending wrong messages (/showthread.php?tid=154173)



dcmd_givecash IS working but sending wrong messages - Andy_McKinley - 12.06.2010

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;
}



Re: dcmd_givecash IS working but sending wrong messages - NitroSWA - 12.06.2010

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


dcmd_givecash IS working but sending wrong messages - [NoV]LaZ - 12.06.2010

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


Re: dcmd_givecash IS working but sending wrong messages - Flashy - 12.06.2010

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;
}




Re: dcmd_givecash IS working but sending wrong messages - NitroSWA - 12.06.2010

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


Re: dcmd_givecash IS working but sending wrong messages - aircombat - 12.06.2010

Код:
//------------------------------[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;
}



Re: dcmd_givecash IS working but sending wrong messages - Hijolion - 06.08.2010

You have str twice in the command.


Re: dcmd_givecash IS working but sending wrong messages - HuRRiCaNe - 06.08.2010

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.


Re: dcmd_givecash IS working but sending wrong messages - Kar - 06.08.2010

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.