21.02.2017, 21:35
Them dialog boxes are driving me CRAZY! No matter what I do, and how I do it, they just won't work.
I am trying to create a dialog box with a list and I'm following this tutorial:
https://sampwiki.blast.hk/wiki/OnDialogResponse
I added the following code to my filterscript:
This is my code:
This is EXTREMELY frustrating. The ShowPlayerDialog part is working as intended, while OnDialogResponse, on the other hand, will not work, no matter how I try to implement it. The code compiles just fine.
I am trying to create a dialog box with a list and I'm following this tutorial:
https://sampwiki.blast.hk/wiki/OnDialogResponse
I added the following code to my filterscript:
Код:
#define DIALOG_WEAPONS 3 // In some command ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close"); 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 switch(listitem) { case 0: GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle case 1: GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47 case 2: GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun } } return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText. } return 0; // You MUST return 0 here! Just like OnPlayerCommandText. }
Код:
// This is a comment // uncomment the line below if you want to write a filterscript #define FILTERSCRIPT #include <a_samp> #include <streamer> new cityHallPickup; new welcomeCityHall; #define DIALOG_WEAPONS 3 #if defined FILTERSCRIPT public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Blank Filterscript by your name here"); print("--------------------------------------\n"); // Creating the rotating 3D info pickup. cityHallPickup = CreatePickup(1239, 1, 362.0000, 174.0000, 1008.0000, -1); // Creating a dynamic sphere. When a player enters it, a dialog box with a list pops up (line 121). cityHallPickup = CreateDynamicSphere(362.000, 174.0000, 1008.0000, 2.0000, -1, -1, -1); // Creating a dynamic sphere. When a player enters it, they are sent the message "( ! ) Welcome to the City Hall". welcomeCityHall = CreateDynamicSphere(362.000, 174.0000, 1008.0000, 50.0000, -1, -1, -1); // Creating a large fuel tank inside Unity Station. CreateObject(13025, 1790.000000, -1930.000000, 15.000000, 0.0, 0.0, 90.0, 300.0); return 1; } public OnFilterScriptExit() { return 1; } #else main() { print("\n----------------------------------"); print(" Blank Gamemode by your name here"); print("----------------------------------\n"); } #endif public OnGameModeInit() { // Don't use these lines if it's a filterscript /* SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; */ } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } public OnPlayerConnect(playerid) { return 1; } public OnPlayerDisconnect(playerid, reason) { return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (!strcmp("/weapons", cmdtext)) { return 1; } return 0; } public OnPlayerEnterDynamicArea(playerid, areaid) { // If the player is in the dynamic sphere (line 26), a dialog box with a list pops up. /* if (areaid == cityHallPickup){ ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "City Hall", "Help\n\ Get a job\n\ Upgrade your current job\n\ Get a job\n\ Resign from your current job\n", "Select", "Cancel"); } */ if (areaid == cityHallPickup){ ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close"); } /* If the player is in the dynamic spehere (line ), they are sent two messages: "( ! ) Welcome to the City Hall!", followed by "( ! ) Fighting is forbidden here!". */ if (areaid == welcomeCityHall){ SendClientMessage(playerid, 0xFFFFFFFF, "( ! ) Welcome to the City Hall!"); SendClientMessage(playerid, 0xFFFFFFFF, "( ! ) Fighting is forbidden here!"); } } 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 switch(listitem) { case 0: GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle case 1: GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47 case 2: GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun } } return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText. } return 0; // You MUST return 0 here! Just like OnPlayerCommandText. } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }