Givecash command bug
#1

i have givecash command but i want to make it that play cant send money to himself and when player send money he will see how much he send and to ho he send and make gametext for player that shows how much money player got
Код:
dcmd_gc(playerid, params[])
{
    new giveplayerid, money;
    if(sscanf(params, "ui", giveplayerid, money)) return SendClientMessage(playerid, -1, "Usage: /gc [playerid/PartOfname] [money]");
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "This player is not connected.");
    GivePlayerMoney(giveplayerid, money);
    SendClientMessage(playerid, -1, "You've sent someone cash.");
    SendClientMessage(giveplayerid, -1, "You recieved cash.");
    return 1;
}
Reply
#2

any help?
Reply
#3

Quote:
Originally Posted by Beljulji
Посмотреть сообщение
any help?
Im just having a look and a test of a code for you bare with me
Reply
#4

*****
Reply
#5

not at all when i want to send money or just type /gc without ID and money says "You can't give yourself cash!"
Reply
#6

Here!

Код:
dcmd_gc(playerid, params[])
{
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds");
	else
	{
		GivePlayerMoney(giveplayerid, amount);
		GivePlayerMoney(playerid, 0 - amount);
		SendClientMessage(playerid, 0x00FF00AA, "Money sent");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Money received");
	}
	return 1;
}
Reply
#7

Here you go this should work.

Код:
dcmd_gc(playerid, params[])
{
    new giveplayerid, amount,name1[24], name2[24], string[128];
    if(!sscanf(params, "ui",giveplayerid,amount)) SendClientMessage(playerid, -1,"Usage: /givecash [ID][Amount]");
    if(playerid != giveplayerid) SendClientMessage(playerid, -1,"You can't pay to yourself.");
    if(GetPlayerMoney(playerid) >= amount) SendClientMessage(playerid, -1,"You don't have that much.");
    GetPlayerName(playerid, name1, 24);
    GetPlayerName(giveplayerid, name2, 24);
    format(string, sizeof(string), "You gave $%d to %s.",amount,name2);
    SendClientMessage(playerid, 0xFFFF00FF, string);
    format(string, sizeof(string), "%s gave you $%d!", name1, amount);
    SendClientMessage(giveplayerid, 0xFFFF00FF, string);
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    return 1;
}
Reply
#8

Quote:
Originally Posted by guitarmandanny
Посмотреть сообщение
Here you go this should work.

Код:
dcmd_gc(playerid, params[])
{
    new giveplayerid, amount,name1[24], name2[24], string[128];
    if(!sscanf(params, "ui",giveplayerid,amount)) SendClientMessage(playerid, -1,"Usage: /givecash [ID][Amount]");
    if(playerid != giveplayerid) SendClientMessage(playerid, -1,"You can't pay to yourself.");
    if(GetPlayerMoney(playerid) >= amount) SendClientMessage(playerid, -1,"You don't have that much.");
    GetPlayerName(playerid, name1, 24);
    GetPlayerName(giveplayerid, name2, 24);
    format(string, sizeof(string), "You gave $%d to %s.",amount,name2);
    SendClientMessage(playerid, 0xFFFF00FF, string);
    format(string, sizeof(string), "%s gave you $%d!", name1, amount);
    SendClientMessage(giveplayerid, 0xFFFF00FF, string);
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    return 1;
}
doesnt work at all
Reply
#9

Quote:
Originally Posted by WizBoy
Посмотреть сообщение
Here!

Код:
dcmd_gc(playerid, params[])
{
	new
		giveplayerid,
		amount;
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds");
	else
	{
		GivePlayerMoney(giveplayerid, amount);
		GivePlayerMoney(playerid, 0 - amount);
		SendClientMessage(playerid, 0x00FF00AA, "Money sent");
		SendClientMessage(giveplayerid, 0x00FF00AA, "Money received");
	}
	return 1;
}
i can still sen money to myself
Reply
#10

Код:
dcmd_gc(playerid, params[])
{
    new giveplayerid, amount,name1[24], name2[24], string[128];
    if(sscanf(params, "ui",giveplayerid,amount)) return  SendClientMessage(playerid, -1,"Usage: /givecash [ID][Amount]");
    if(playerid == giveplayerid) return SendClientMessage(playerid, -1,"You can't pay to yourself.");
    if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, -1,"You don't have that much.");
    GetPlayerName(playerid, name1, 24);
    GetPlayerName(giveplayerid, name2, 24);
    format(string, sizeof(string), "You gave $%d to %s.",amount,name2);
    SendClientMessage(playerid, 0xFFFF00FF, string);
    format(string, sizeof(string), "%s gave you $%d!", name1, amount);
    SendClientMessage(giveplayerid, 0xFFFF00FF, string);
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    return 1;
}
@guitarmandanny you had a good start
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)