SA-MP Forums Archive
TakePlayerCash? Or - 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: TakePlayerCash? Or (/showthread.php?tid=173286)



TakePlayerCash? Or - Quest123 - 02.09.2010

Hey i can't seem to find it on the wiki, but im trying to make a command like "/weaponspack" it will check how much money you have on you, and if you have enough ( AKA 1Mil ) it will take away your cash and give you the weapons, but i can't seem to find the functions for checking playing money, and taking it away.

Could you help me


Re: TakePlayerCash? Or - Yamoo - 02.09.2010

pawn Код:
if(GetPlayerCash(playerid) >= 1000000) // Checks if the player has it.
                            {
                                GivePlayerCash(playerid,-1000000); // Takes it away.



Re: TakePlayerCash? Or - Quest123 - 02.09.2010

Quote:
Originally Posted by Yamoo
Посмотреть сообщение
pawn Код:
if(GetPlayerCash(playerid) >= 1000000) // Checks if the player has it.
                            {
                                GivePlayerCash(playerid,-1000000); // Takes it away.
So how would i make the command? ( im noob )

pawn Код:
if(strcmp(cmd, "/weaponspack", true) == 0) {
if(GetPlayerCash(playerid) >= 1000000) // Checks if the player has it.
                            {
                                GivePlayerCash(playerid,-1000000); // Takes it away.
GivePlayerWeapon(playerid, 24, 650);
GivePlayerWeapon(playerid, 31, 650);
GivePlayerWeapon(playerid, 26, 650);
SetPlayerHealth(playerid, 100);
SetPlayerArmor(playerid, 100);
return 1;
)
Or what? Also what do i do if he doesn't have enough cash on him?


Re: TakePlayerCash? Or - DiddyBop - 02.09.2010

pawn Код:
if(strcmp(cmd, "/weaponspack", true) == 0) {
if(GetPlayerCash(playerid) >= 1000000) // Checks if the player has it.
                            {
                                GivePlayerCash(playerid,-1000000); // Takes it away.
GivePlayerWeapon(playerid, 24, 650);
GivePlayerWeapon(playerid, 31, 650);
GivePlayerWeapon(playerid, 26, 650);
SetPlayerHealth(playerid, 100);
SetPlayerArmor(playerid, 100);
}else return SendClientMessage(playerid, colorid, "you dont have enough cash!");
return 1;
)
now will work.


Re: TakePlayerCash? Or - Yamoo - 02.09.2010

Add these into your script -

pawn Код:
stock GetPlayerCash(playerid)
{
    return Cash[playerid];
}

stock GivePlayerCash(playerid, money)
{
    Cash[playerid]+=money;
    SetPlayerMoney(playerid,Cash[playerid]);
    return 1;
}
pawn Код:
if(strcmp(cmd, "/weaponspack", true) == 0) {
if(PlayerConnected(playerid))
{
if(GetPlayerCash(playerid) >= 1000000) // Checks if the player has it.
{
GivePlayerCash(playerid,-1000000); // Takes it away.
GivePlayerWeapon(playerid, 24, 650);
GivePlayerWeapon(playerid, 31, 650);
GivePlayerWeapon(playerid, 26, 650);
SetPlayerHealth(playerid, 100);
SetPlayerArmor(playerid, 100);
{
else
}
SendClientMessage(playerid, *COLOR*, "You do not have the right ammount of cash for these items!");
}
return 1;
}
Abit messy, but i'm tired so clean it up abit.. also it's not tested so just let me know.


Re: TakePlayerCash? Or - Quest123 - 02.09.2010

Alright i did it, i get these errors:

Код:
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity150.pwn(35) : error 017: undefined symbol "Cash"
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity150.pwn(35) : warning 215: expression has no effect
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity150.pwn(35) : error 001: expected token: ";", but found "]"
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity150.pwn(35) : error 029: invalid expression, assumed zero
C:\Users\azd\Desktop\samp03bsvr_R2_win32\gamemodes\Fruity150.pwn(35) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
return Cash[playerid];
= line 35


Re: TakePlayerCash? Or - SmugglesJr - 02.09.2010

Код:
if(strcmp(cmd, "/weaponspack", true) == 0) {
if(PlayerConnected(playerid))
{
if(GetPlayerMoney(playerid) >= 1000000) // Checks if the player has it.
{
GivePlayerMoney(playerid,-1000000); // Takes it away.
GivePlayerWeapon(playerid, 24, 650);
GivePlayerWeapon(playerid, 31, 650);
GivePlayerWeapon(playerid, 26, 650);
SetPlayerHealth(playerid, 100);
SetPlayerArmor(playerid, 100);
{
else
}
SendClientMessage(playerid, *COLOR*, "You do not have the right ammount of cash for these items!");
}
return 1;
}
try that


Re: TakePlayerCash? Or - Cameltoe - 02.09.2010

Try addind "new Cash[MAX_PLAYERS];" at the top of your script

you also might want to add this stock to:
pawn Код:
stock SetPlayerCash(playerid, money)
{
     Cash[playerid] = money;
}



Re: TakePlayerCash? Or - Matthias_ - 02.09.2010

Why have double stocks when the functions are already there? Seems a bit of an overkill. Use SmugglesJr's code.


Re: TakePlayerCash? Or - Cameltoe - 02.09.2010

Quote:
Originally Posted by Matthias_
Посмотреть сообщение
Why have double stocks when the functions are already there? Seems a bit of an overkill. Use SmugglesJr's code.
To prevent hacking maybe?