buying in dialog problem
#1

Quote:

if(listitem == 1)
{
if(GetPlayerMoney(playerid) <14999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -15000);
GivePlayerWeapon(playerid, 27, 300);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Combat Shotgun for 100000$");
return 1;
}
}
return 1;
}

This doesnt take away money , and gives you the weapon no matter how much you have, no message comes up either
Reply
#2

show the whole dialogid part and the part where you call the dialog.

(On a side note, <14999 will allow the player to buy the gun with 14999$ getting him into -1)
Reply
#3

maybe?
if(GetPlayerMoney(playerid) <15000) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
Reply
#4

Try this.

pawn Код:
if(listitem == 1)
{
if(GetPlayerMoney(playerid) < 15000) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
new money = GetPlayerMoney(playerid);
GivePlayerMoney(playerid, money-[Put Amount Of Money It Costs Here]);
GivePlayerWeapon(playerid, 27, 300);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Combat Shotgun for 100000$");
return 1;
}
}
return 1;
}
Reply
#5

Neither of the solutions will work, especially the last one.
Reply
#6

I don't know what the 2 extra }'s are for.. so try

pawn Код:
if(listitem == 1)
{
    if(GetPlayerMoney(playerid) < 15000)
        return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
       
    GivePlayerMoney(playerid, -15000);
    GivePlayerWeapon(playerid, 27, 300);
    SendClientMessage(playerid,COLOR_GREEN,"You bought a Combat Shotgun for $15000.");
    return 1;
}
Reply
#7

whole code
Quote:

#include <a_samp>
#include <zcmd>
#define COLOR_RED 0xFF0000AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_GREEN 0x33AA33AA
#define DIALOGID 3
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOGID)
{
if(response)
{
if(listitem == 0)
{
ShowPlayerDialog(playerid, DIALOGID+1, DIALOG_STYLE_LIST, "Melee weapons", "Knuckle Dusters-1000$\nGolf Club-1010$\nNite Stick-1100$\nKnife-10000$\nBat-100$\nShovel-200$\nPool Cue-1500$\nKatana-10000$\nDildo-1000$\n", "Buy", "Cancel");
}
if(listitem == 1)
{
ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Pistols", "9mm-2500$\nSilenced 9mm-3000$\nDesert Eagle-10000$", "Buy", "Cancel");
}
if(listitem == 2)
{
ShowPlayerDialog(playerid, DIALOGID+3, DIALOG_STYLE_LIST, "SMG's", "Uzi-25000$\nSMG-30000$\nTec9-20000$", "Buy", "Cancel");
}
if(listitem == 3)
{
ShowPlayerDialog(playerid, DIALOGID+4, DIALOG_STYLE_LIST, "Rifles", "Country Rifle-25000$\nSniper Rifle-50000$", "Buy", "Cancel");
}
if(listitem == 4)
{
ShowPlayerDialog(playerid, DIALOGID+5, DIALOG_STYLE_LIST, "Heavy guns", "AK-47-30000$\nM4-40000$", "Buy", "Cancel");
}
if(listitem == 5)
{
ShowPlayerDialog(playerid, DIALOGID+6, DIALOG_STYLE_LIST, "Shotguns", "Standard Shotgun-10000$\nCombat Shotgun-100000$", "Buy", "Cancel");
}
}
return 1;
}

if(dialogid == DIALOGID+1)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 1, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought Knuckle Dusters for 1000$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <1009) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -1010);
GivePlayerWeapon(playerid, 2, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Golf Club for 1010$");
return 1;
}
if(listitem == 2)
{
if(GetPlayerMoney(playerid) <1099) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -1100);
GivePlayerWeapon(playerid, 3, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Nite Stick for 1100$");
return 1;
}
if(listitem == 3)
{
if(GetPlayerMoney(playerid) <9999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 4, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Knife for 10000$");
return 1;
}
if(listitem == 4)
{
if(GetPlayerMoney(playerid) <99) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -100);
GivePlayerWeapon(playerid, 5, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Baseball Bat for 100$");
return 1;
}
if(listitem == 5)
{
if(GetPlayerMoney(playerid) <199) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -200);
GivePlayerWeapon(playerid, 6, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Shovel for 200$");
return 1;
}
if(listitem == 6)
{
if(GetPlayerMoney(playerid) <1499) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -1500);
GivePlayerWeapon(playerid, 7, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Pool Cue for 1500$");
return 1;
}
if(listitem == 7)
{
if(GetPlayerMoney(playerid) <9999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 8, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Katana for 10000$");
return 1;
}
if(listitem ==
{
if(GetPlayerMoney(playerid) <999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -1000);
GivePlayerWeapon(playerid, 10, 1);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Dildo for 1000$");
return 1;
}
}
return 1;
}

if(dialogid == DIALOGID+2)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <2499) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -2500);
GivePlayerWeapon(playerid, 22, 500);
SendClientMessage(playerid,COLOR_GREEN,"You bought a 9mm for 2500$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <2999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -3000);
GivePlayerWeapon(playerid, 23, 500);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Silenced 9mm for 3000$");
return 1;
}
if(listitem == 2)
{





if(GetPlayerMoney(playerid) <9999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 24, 100);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Desert Eagle for 10000$");
return 1;
}
}
return 1;
}

if(dialogid == DIALOGID+3)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <24999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -25000);
GivePlayerWeapon(playerid, 28, 500);
SendClientMessage(playerid,COLOR_GREEN,"You bought an Uzi for 25000$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <29999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -30000);
GivePlayerWeapon(playerid, 29, 500);
SendClientMessage(playerid,COLOR_GREEN,"You bought an SMG for 30000$");
return 1;
}
if(listitem == 2)
{
if(GetPlayerMoney(playerid) <19999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -20000);
GivePlayerWeapon(playerid, 32, 500);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Tec-9 for 20000$");
return 1;
}
}
return 1;
}

if(dialogid == DIALOGID+4)
{
if(response)
{
if(listitem == 0)
{

if(GetPlayerMoney(playerid) <24999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -25000);
GivePlayerWeapon(playerid, 33, 100);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Country Rifle for 5000$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <49999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -50000);
GivePlayerWeapon(playerid, 34, 100);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Sniper Rifle for 50000$");
return 1;
}
}
return 1;
}

if(dialogid == DIALOGID+5)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <29999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -30000);
GivePlayerWeapon(playerid, 30, 300);
SendClientMessage(playerid,COLOR_GREEN,"You bought an AK-47 for 30000$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <39999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -40000);
GivePlayerWeapon(playerid, 31, 300);
SendClientMessage(playerid,COLOR_GREEN,"You bought an M4 for 40000$");
return 1;
}
}
return 1;
}

if(dialogid == DIALOGID+6)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) <9999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, 25, 100);
SendClientMessage(playerid,COLOR_GREEN,"You a bought a Shotgun for 10000$");
return 1;
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) <14999) return SendClientMessage(playerid,COLOR_RED, "You do not have enough money.");
GivePlayerMoney(playerid, -15000);
GivePlayerWeapon(playerid, 27, 300);
SendClientMessage(playerid,COLOR_GREEN,"You bought a Combat Shotgun for 100000$");
return 1;
}
}
return 1;
}



return 0;
}
CMD:buyguns(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "Weapon List", "Melee weapons\nPistols\nSub-Machine Guns\nRifle's\nAssault Rifle's\nShotguns", "Select", "Cancel");
return 1;
}
Reply
#8

Is it a filterscript included in your main gamemode? If so then the main gamemode might have custom functions to set money (scripted money, anticheats...) and thus the default SA:MP functions might not affect the player's actual money.

Also you're removing 15000 from the player, not 100000 as the message states.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)