Small gun store system
Requirements
I don't know if anyones created anything like this, I guess they have.. But the past week I've really gotten into scripting again and started to teach myself more and tonight I got bored and decided to create a small /buyguns system for roleplay servers. Someone would of already created something similar to this, but I just wanted to present my work. It's not too advanced, but it's simple for people who are beginning to script like me. It's not really a filterscript, it's just a small script you can add directly into your gamemode. If you like you can add it as a filterscript. Tell me if it's good or not and what features I can add to improve it. Thanks!
I will add some captions for beginners;
At the top of your script (Make sure you have the include)
You will also need to define the dialog we are creating;
Код:
#define DIALOGWEAPONS 1
The command;
Код:
CMD:buyguns(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 40, 286.148986,-40.644397,1001.515625) || IsPlayerInRangeOfPoint(playerid, 40, 286.800994,-82.547599,1001.515625) || IsPlayerInRangeOfPoint(playerid, 40, 296.919982,-108.071998,1001.515625) || IsPlayerInRangeOfPoint(playerid, 40, 314.820983,-141.431991,999.601562) || IsPlayerInRangeOfPoint(playerid, 40, 316.524993,-167.706985,999.593750))
ShowPlayerDialog(playerid, DIALOGWEAPONS, DIALOG_STYLE_LIST, "Hello, what guns can I get you?", "Deagle(15k)\nShotgun(2.5k)\nMP5(5k)\nSpas12(170k)\n(50k)\n(60k)\nSniper(150k)\nHalf vest(10k)\nFull vest(20k)","Buy","Cancel");
return 1;
}
Under OnDialogResponse;
Код:
if(dialogid == DIALOGWEAPONS)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) <1500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a deagle for 15k!");
GivePlayerMoney(playerid, -1500);
GivePlayerWeapon(playerid,24, 9999999);
}
case 1:
{
if(GetPlayerMoney(playerid) <2500) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a shotgun for 2.5k!");
GivePlayerMoney(playerid, -2500);
GivePlayerWeapon(playerid, 25, 9999999);
}
case 2:
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an MP5 for 5k!");
GivePlayerMoney(playerid, -5000);
GivePlayerWeapon(playerid, 29 ,9999999);
}
case 3:
{
if(GetPlayerMoney(playerid) <170000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a spas12 for 170k!");
GivePlayerMoney(playerid, -170000);
GivePlayerWeapon(playerid, 27, 9999999);
}
case 4:
{
if(GetPlayerMoney(playerid) <50000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an for 50k!");
GivePlayerMoney(playerid, -50000);
GivePlayerWeapon(playerid,30 ,9999999);
}
case 5:
{
if(GetPlayerMoney(playerid) <60000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought an for 60k!");
GivePlayerMoney(playerid, -60000);
GivePlayerWeapon(playerid, 31, 9999999);
}
case 6:
{
if(GetPlayerMoney(playerid) <150000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a sniper for 150k!");
GivePlayerMoney(playerid, -150000);
GivePlayerWeapon(playerid, 34, 9999999);
}
case 7:
{
if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 100) return SendClientMessage(playerid, COLOR_GRAD,"You already have a full vest!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a half vest for 10k!");
GivePlayerMoney(playerid, -10000);
SetPlayerArmour(playerid, 50);
}
case 8:
{
if(GetPlayerMoney(playerid) <20000) return SendClientMessage(playerid, COLOR_GRAD, "You don't have enough money to buy this item!");
new Float:armour;
GetPlayerArmour(playerid, armour);
if(armour == 100) return SendClientMessage(playerid, COLOR_GRAD, "You already have a full vest!");
SendClientMessage(playerid, COLOR_GRAD, "You bought a full vest for 20k!");
GivePlayerMoney(playerid, -20000);
SetPlayerArmour(playerid, 100);
}
}
return 1;
}
}
If this is your last dialog, make sure you return 0.
I also created a quick teleport command so you can teleport straight to the interiors to test it out, if you want this, add it to your script.
Код:
CMD:gunstore(playerid, params[])
{
if(strcmp(params,"1",true) == 0)
{
SetPlayerPos(playerid, 286.148986,-40.644397,1001.515625);
SetPlayerInterior(playerid, 1);
GivePlayerMoney(playerid, 50000);
}
else if(strcmp(params,"2",true) == 0)
{
SetPlayerPos(playerid, 286.800994,-82.547599,1001.515625);
SetPlayerInterior(playerid, 4);
}
else if(strcmp(params, "3",true) == 0)
{
SetPlayerPos(playerid, 296.919982,-108.071998,1001.515625);
SetPlayerInterior(playerid, 6);
}
else if(strcmp(params, "4",true) == 0)
{
SetPlayerPos(playerid, 314.820983,-141.431991,999.601562);
SetPlayerInterior(playerid, 7);
}
else if(strcmp(params, "5",true) == 0)
{
SetPlayerPos(playerid, 316.524993,-167.706985,999.593750);
SetPlayerInterior(playerid, 6);
}
return 1;
}
If you find any bugs in this script, please let me know. Also, if I have done anything wrong feel free to correct me as I am only learning
P.s I have also created a small /buydrinks system aswell, if you want it PM me and ill send you the code
Thanks, have fun!
Nice work, the ability to shorten and straighten with an array, yet very beautiful!