dcmd_givecash
#1

does any1 have a simple dcmd_givecash the one off wiki is pretty lame and i need one thanks
Reply
#2

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(givecash, 8, cmdtext);
	return 0;
}
 
dcmd_givecash(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
#3

Just 1 tip, use [pawn] inteasted of [code] Just for perfomance
Reply
#4

like i said not the one of wiki cant you read? and that one you can send your self money -.-
Reply
#5

bump
Reply
#6

pawn Код:
dcmd_givecash(playerid, params[])
{
    new id, amount, name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME], string[128];
    if (sscanf(params, "ud", id, amount)) SendClientMessage(playerid, -1, "Usage: /givecash <playerid/name> <amount of cash>");
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, "This player is not connected");
    if(id == playerid) SendClientMessage(playerid, -1, "You can't give money to yourself");
    if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, -1, "You don't have enough money");
    if(amount < 1) SendClientMessage(playerid, -1, "You can not give less than 1 dollar");

    else
    {
        GetPlayerName(id, name, sizeof(name));
        GetPlayerName(playerid, name2, sizeof(name2));
        GivePlayerMoney(id, amount);
        GivePlayerMoney(playerid, 0 - amount);
        format(string, sizeof(string), "You gave $%d to %s",amount, name);
        format(string, sizeof(string), "You recived $%d from %s",amount, name2);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(id, -1, string);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by xir
Посмотреть сообщение
pawn Код:
dcmd_givecash(playerid, params[])
{
    new id, amount, name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME], string[128];
    if (sscanf(params, "ud", id, amount)) SendClientMessage(playerid, -1, "Usage: /givecash <playerid/name> <amount of cash>");
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, "This player is not connected");
    if(id == playerid) SendClientMessage(playerid, -1, "You can't give money to yourself");
    if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, -1, "You don't have enough money");
    if(amount < 1) SendClientMessage(playerid, -1, "You can not give less than 1 dollar");

    else
    {
        GetPlayerName(id, name, sizeof(name));
        GetPlayerName(playerid, name2, sizeof(name2));
        GivePlayerMoney(id, amount);
        GivePlayerMoney(playerid, 0 - amount);
        format(string, sizeof(string), "You gave $%d to %s",amount, name);
        format(string, sizeof(string), "You recived $%d from %s",amount, name2);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(id, -1, string);
    }
    return 1;
}
thanks :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)