[Help]prices
#1

Hello,
im sorry,i know ive asked a lot of questions lately,im just starting to script and i need some tips.
i've just built a weapons menu,but they're free ><
i need to know how to create prices for each weapon.
For example ,if a weapon cost 1500$,i've tried to do GivePlayerMoney(playerid,-1500);
it works,BUT,it gets the player -1500$ even if he have 0$,so it comes red and suddently i have -1500$,shows on my HUD,
but i need to make ,that like if a player have 1000$,it will say "You dont have enough money to buy this item".
Thanks in advance.

PS:if you just give me an example for only one weapon,its good i will understand how,and i'll do it for all rest
if the menu script is required,ask me
i tried to search for other topics that require help like i do,but i didnt find,so i started a new one,if i there is already a topic like this,please excuse me,and link me the other topic so i can browse it.
Reply
#2

Example #1:
pawn Код:
if(GetPlayerMoney(playerid) < 1500)
{
  // not enough money.
}
else
{
  // enough money.
}
Example #2:
pawn Код:
if(GetPlayerMoney(playerid) >= 1500)
{
  // enough money.
}
else
{
  // not enough money.
}
Reply
#3

Quote:
Originally Posted by Don Correlli
Example #1:
pawn Код:
if(GetPlayerMoney(playerid) < 1500)
{
  // not enough money.
}
else
{
  // enough money.
}
Example #2:
pawn Код:
if(GetPlayerMoney(playerid) >= 1500)
{
  // enough money.
}
else
{
  // not enough money.
}
Ty very much
Reply
#4

Hmm..
look what i've done(tried only on one weapon)
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:current1;
  current1 = GetPlayerMenu(playerid);
  if(current1 == weaponmenu)
{
  switch(row)
  {
    case 0: //Desert eagle
        {
    if(GetPlayerMoney(playerid) >= 5000)
        GivePlayerMoney(playerid,-5000);
        SendClientMessage(playerid,0xAA3333AA,"You have bought a Desert eagle");
        else
        if(GetPlayerMoney(playerid) < 5000)
        SendClientMessage(playerid,0xAA3333AA,"You dont have enough money To buy this Item,You need 5000$");
        }
Script continues..
And errors:
pawn Код:
C:\Users\Avi\Desktop\Dm server\gamemodes\Dm-S.pwn(781) : error 029: invalid expression, assumed zero
C:\Users\Avi\Desktop\Dm server\gamemodes\Dm-S.pwn(781 -- 782) : warning 215: expression has no effect
C:\Users\Avi\Desktop\Dm server\gamemodes\Dm-S.pwn(782) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
What did i do wrong?
Reply
#5

pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:current1;
  current1 = GetPlayerMenu(playerid);
  if(current1 == weaponmenu)
  {
    switch(row)
    {
        case 0: //Desert eagle
        {
            if(GetPlayerMoney(playerid) >= 5000)
            {
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,0xAA3333AA,"You have bought a Desert eagle");
            }
            else
            {
                SendClientMessage(playerid,0xAA3333AA,"You dont have enough money To buy this Item,You need 5000$");
            }
        }
Reply
#6

Quote:
Originally Posted by MadeMan
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:current1;
  current1 = GetPlayerMenu(playerid);
  if(current1 == weaponmenu)
  {
    switch(row)
    {
        case 0: //Desert eagle
        {
            if(GetPlayerMoney(playerid) >= 5000)
            {
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,0xAA3333AA,"You have bought a Desert eagle");
            }
            else
            {
                SendClientMessage(playerid,0xAA3333AA,"You dont have enough money To buy this Item,You need 5000$");
            }
        }
Ahhh!!
Thank you so much worked
ty ty ty ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)