26.02.2012, 00:23
My first filterscipt!
Hello! I am relatively new to scripting in the SA-MP community and had a lot of helpful answers to help develop this script thanks to the SA-MP wiki! I am going to release my General Store script which is noob-friendly out to the community and for noobs that may need it!OnPlayerCommandText
PHP Code:
if(strcmp(cmdtext,"/buy",true)==0)
if(IsPlayerInRangeOfPoint(playerid, 10.0, -30.8246,-28.4104,1003.5573))
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Shop List","$59 - Condoms\n$9 - Chips\n$5 - Cola\n$6 - Burger\n$680 - Safety Vest\n$125 - Camera\n$35 - Baseball Bat\n$54 - Wooden Cane\n$39 - Golf Club\n$25 - Flowers ","Purchase","Exit");
return 1;
}
PHP Code:
if(dialogid==1 && response==1)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) <59) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid,0xFF9900AA,"You have bought condoms for $59!");
GivePlayerMoney(playerid, -59);
SetPlayerArmour(playerid, pArmour+5);
}
case 1:
{
if(GetPlayerMoney(playerid) <9) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a bag of chips for $9");
GivePlayerMoney(playerid, -9);
ApplyAnimation(playerid,"VENDING", "vend_eat1_P",4.1,0,1,1,1,1,1);
}
case 2:
{
if(GetPlayerMoney(playerid) <5) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pHealth;
GetPlayerHealth(playerid, Float:pHealth);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a can of cola for $5");
GivePlayerMoney(playerid, -5);
SetPlayerHealth(playerid, pHealth+2);
}
case 3:
{
if(GetPlayerMoney(playerid) <6) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a burger for $6");
SetPlayerAttachedObject(playerid, 4, 2880, 5);
GivePlayerMoney(playerid, -6);
ApplyAnimation(playerid,"VENDING", "vend_eat1_P",4.1,0,1,1,1,1,1);
SetPlayerArmour(playerid, pArmour+3);
SendClientMessage(playerid, 0xD6D6D6AA, "((Use {219900}/removeobjects{D6D6D6} to remove the object!))");
}
case 4:
{
if(GetPlayerMoney(playerid) <680) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a vest for $680");
GivePlayerMoney(playerid, -680);
SetPlayerArmour(playerid, pArmour+35);
}
case 5:
{
if(GetPlayerMoney(playerid) <125) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a {13D4A3}Camera{D6D6D6} for $125");
GivePlayerMoney(playerid, -125);
GivePlayerWeapon(playerid, 43, 100);
}
case 6:
{
if(GetPlayerMoney(playerid) <35) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a {13D4A3}Baseball Bat{D6D6D6} for $35");
GivePlayerMoney(playerid, -35);
GivePlayerWeapon(playerid, 5, 0);
}
case 7:
{
if(GetPlayerMoney(playerid) <54) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a {13D4A3}Wooden Cane{D6D6D6} for $54");
GivePlayerMoney(playerid, -54);
GivePlayerWeapon(playerid, 15, 0);
}
case 8:
{
if(GetPlayerMoney(playerid) <39) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased a {13D4A3}Golf Club{D6D6D6} for $39");
GivePlayerMoney(playerid, -39);
GivePlayerWeapon(playerid, 2, 0);
}
case 9:
{
if(GetPlayerMoney(playerid) <25) return SendClientMessage(playerid,0xAA3333AA, "You do not have enough money!");
new Float:pArmour;
GetPlayerArmour(playerid, Float:pArmour);
SendClientMessage(playerid, 0xD6D6D6AA, "You purchased {13D4A3}Flowers{D6D6D6} for $25");
GivePlayerMoney(playerid, -25);
GivePlayerWeapon(playerid, 14, 0);
}
}
}
return 1;
}
What does it do?
This script inserts a /buy command at the coordinates. Feel free to change the coordinates to your liking, when you do, type /buy near the new location and you will see a Dialog box. You can then purchase various items from the list. You may change the items, and if you need any help feel free to ask. This is a general script, and it is ready to use, ALL you HAVE to do is change the coordinates of the store.
Pictures
Note: If you appreciate my work, feel free to leave a +rep for my first release!