SA-MP Forums Archive
How to make /givemoney and /giveweapon? - 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)
+--- Thread: How to make /givemoney and /giveweapon? (/showthread.php?tid=546536)



How to make /givemoney and /giveweapon? - C0olp1x - 16.11.2014

How can i make commands like /givemoney [playerid] and /giveweapon [playerid]

Like if u have 1000 money and u try to give someone 100000 it says "u don't have that kind of money" or something ... PLSSSSS HELP !


Re: How to make /givemoney and /giveweapon? - Abagail - 16.11.2014

Use GivePlayerMoney, and GetPlayerMoney to give / get the amount of cash.

Example:
pawn Код:
CMD:givecash(playerid, params[])
{
   if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessage(playerid, -1, "USAGE: /givecash [id] [amount]");
   if(IsPlayerConnected(giveplayerid))
   {
       if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, -1, "You don't even have that much.");
       GivePlayerMoney(playerid, -amount);
       GivePlayerMoney(giveplayerid, amount);
       return 1;
   }
}
return true;
}



Re: How to make /givemoney and /giveweapon? - C0olp1x - 16.11.2014

I got 2 warnings ...
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1892) : warning 203: symbol is never used: "givecash"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1892) : warning 203: symbol is never used: "ret_memcpy"


Re: How to make /givemoney and /giveweapon? - C0olp1x - 16.11.2014

Doesn't work ... !


Re: How to make /givemoney and /giveweapon? - Abagail - 16.11.2014

You'll need to include ZCMD by placing this under the a_samp include line:
pawn Код:
#include zcmd



Re: How to make /givemoney and /giveweapon? - C0olp1x - 16.11.2014

C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1884) : error 017: undefined symbol "giveplayerid"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1885) : error 017: undefined symbol "giveplayerid"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1887) : error 017: undefined symbol "amount"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(188 : error 017: undefined symbol "amount"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1889) : error 017: undefined symbol "giveplayerid"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1892) : warning 209: function "cmd_givecash" should return a value
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1893) : error 010: invalid function or declaration
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1896) : error 017: undefined symbol "givecash"

i got these errors ....


Re: How to make /givemoney and /giveweapon? - AlphaPac - 16.11.2014

You need to download zcmd and include it into your gamemode.

pawn Код:
CMD:givecash(playerid, params[])
{
    new giveplayerid, amount;
    if(sscanf(params, "ud", giveplayerid, amount)) return SendClientMessage(playerid, -1, "USAGE: /givecash [id] [amount]");
    if(IsPlayerConnected(giveplayerid))
    {
        if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, -1, "You don't even have that much.");
        GivePlayerMoney(playerid, -amount);
        GivePlayerMoney(giveplayerid, amount);
        return 1;
    }
    return 1;
}



Re: How to make /givemoney and /giveweapon? - HY - 16.11.2014

pawn Код:
CMD:givecash(playerid, params[])
{
    new ID, Money;
    new string[128];
    if(sscanf(params, "ii", ID, Money)) return SendClientMessage(playerid, -1, "USAGE: /GiveCash [ID] [Amount]");
    if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid, -1, "You don't even have that much.");
    GivePlayerMoney(playerid, -amount);
    GivePlayerMoney(giveplayerid, amount);
    format(string, sizeof(string), "You succesfully gaved %i $ to %s !", Money, ID);
    SendClientMessage(playerid, -1, string);
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "You received %i money from %s !", Money, name);
    SendClientMessage(ID, -1, string);
    return 1;
}
pawn Код:
CMD:giveweapon(playerid, params[])
{
    new ID;
    new Weapon;
    new Ammo;
    if(sscanf(params, "iii", ID, Weapon, Ammo)) return SendClientMessage(playerid, -1, "USAGE: /GiveWeapon [ID] [Weapon] [Ammo]");
    GivePlayerWeapon(ID, Weapon, Ammo);
    return 1;
}



Re: How to make /givemoney and /giveweapon? - dominik523 - 16.11.2014

Quote:
Originally Posted by C0olp1x
Посмотреть сообщение
How can i make commands like /givemoney [playerid] and /giveweapon [playerid]

Like if u have 1000 money and u try to give someone 100000 it says "u don't have that kind of money" or something ... PLSSSSS HELP !
That "you don't have that kind of money" is not so hard to make, and if you don't know it, I'm sure you got some things to learn like writing command with ZCMD or some other command processor and using sscanf2 include.
You need to have your money defined in your script (enums and that stuff), we don't know names of your variables.


Re : How to make /givemoney and /giveweapon? - Dutheil - 16.11.2014

https://sampforum.blast.hk/showthread.php?tid=280476