TakePlayerCash? Or
#1

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
Reply
#2

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

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?
Reply
#4

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.
Reply
#5

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.
Reply
#6

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
Reply
#7

Код:
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
Reply
#8

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;
}
Reply
#9

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)