17.11.2012, 15:12
Introduction
__________________
Hello guys, this is my first tutorial, and today we will be making a /shop or /buygun depending if you want it on a Roleplay or a DeathMatch server. Im gonna try to make this simple as possible. So Lets get started.
___________________________________________
Step 1:Lets start off by opening up a new pawno, adding #define DIALOG_WEAPONS 1 under #include <a_samp>. After that is done we are going to make the cmd name (full script will be shown after).
Im just gonna start dragging the script in so its a little faster
Step 2: Adding the dialog, the dialog is one of the most important things in this script, we are going to use a List box for the dialog.
Put that under
So it looks like this:
Your pretty Much done with that. You can add:
If you want it to be in a interior or anywhere. Now lets do our OnDialogResponse
_____________________
Now usally you can fine the OnDialogResponse in a new pawno, or easydialog by Emmet_ So you can use either of those but im gonna use the one in pawno.
Here is the full code
Credits to:
Emmet_ for easy dialog
cluckintucker
Download
EasyDialog include by Emmet_ http://www.pastebin.com/raw.php?i=TGKmPZQa
Full Dialog weapon script by cluckin tucker http://pastebin.com/rcYLXytc
__________________
Hello guys, this is my first tutorial, and today we will be making a /shop or /buygun depending if you want it on a Roleplay or a DeathMatch server. Im gonna try to make this simple as possible. So Lets get started.
___________________________________________
Step 1:Lets start off by opening up a new pawno, adding #define DIALOG_WEAPONS 1 under #include <a_samp>. After that is done we are going to make the cmd name (full script will be shown after).
Code:
if (strcmp("/buygun", cmdtext, true, 10) == 0)
Step 2: Adding the dialog, the dialog is one of the most important things in this script, we are going to use a List box for the dialog.
Code:
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun\nM4\nShotgun\n[add a gun here]", "Select", "Close");
Code:
if (strcmp("/buygun", cmdtext, true, 10) == 0) {
Code:
if (strcmp("/buygun", cmdtext, true, 10) == 0) { ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close"); return 1; } return 0; }
Code:
if (IsPlayerInRangeOfPoint(playerid,"x,y,z"); ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close"); else SendClientMessage(playerid,color_red,"Your not at the right point"); return 1;
_____________________
Now usally you can fine the OnDialogResponse in a new pawno, or easydialog by Emmet_ So you can use either of those but im gonna use the one in pawno.
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_WEAPONS) { if(response) // If they clicked select. { // Give them the weapon if(listitem == 0) // They selected the Desert Eagle { GivePlayerWeapon(playerid, 24, 2000); // Give them a desert eagle // You can add GivePlayerMoney(playerid, -2000) if you want it to take money, you can do it on all of the weapons you want } if(listitem == 1) // They selected the second item - AK-47 { GivePlayerWeapon(playerid, 31, 120); // Give them an AK-47 } if(listitem == 2) // They selected the third item - Desert Eagle { GivePlayerWeapon(playerid, 27, 28); // Give them a Combat Shotgun } if(listitem == 3) // if they chose m4 { GivePlayerWeapon(playerid,31,30); } if(listitem == 4) // they chose shotgun } return 1; }
Code:
if (strcmp("/buygun", cmdtext, true, 10) == 0) { ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close"); return 1; } return 0; }
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_WEAPONS) { if(response) // If they clicked 'Select' or double-clicked a weapon { // Give them the weapon if(listitem == 0) // They selected the first item - Desert Eagle { GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle } if(listitem == 1) // They selected the second item - AK-47 { GivePlayerWeapon(playerid, 31, 120); // Give them an AK-47 } if(listitem == 2) // They selected the third item - Desert Eagle { GivePlayerWeapon(playerid, 27, 28); // Give them a Combat Shotgun } if(listitem == 3) { GivePlayerWeapon(playerid,41,30); } if(listitem == 4) { GivePlayerWeapon(playerid, 25, 30); } return 1; } return 0; }
Emmet_ for easy dialog
cluckintucker
Download
EasyDialog include by Emmet_ http://www.pastebin.com/raw.php?i=TGKmPZQa
Full Dialog weapon script by cluckin tucker http://pastebin.com/rcYLXytc