Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define CARSPAWND 21929
- public OnFilterScriptInit()
- {
- print("Vehicle Spawner loaded. Script by Andrus Riis(Mr Dzx)");
- return 1;
- }
- //Removed OnFilterScriptExit - Wasn't being used
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- //Removed "new cmd[128];" - No requirement for it
- //Changed "cmd" to "cmdtext[1]", the "cmd" variable had been newly assigned, so would be null. String comparing to it would have failed as the string would have contained nothing.
- //Changed the == 0 to ! as its evaluated slightly faster
- if(!strcmp(cmdtext[1], "carspawn", true))
- {
- ShowPlayerDialog(playerid, CARSPAWND, DIALOG_STYLE_INPUT, "Car Spawner", "Please type in car model id you want to spawn.\n\nNB! For full list of car model ID's, please visit weedarr.com", "Spawn", "Cancel");
- //This "return 1;" was missing from inside the code, OnPlayerCommandText has to return 0 to continue processing the commands in other scripts (i.e the gamemode).
- return 1;
- }
- //Heres the return 0 you need.
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- //This switch case statement makes it easier to add more dialogs to the system for future expansion.
- switch(dialogid)
- {
- case CARSPAWND:
- {
- if(response)
- {
- //Moved the creation of new variables and functions inside the response check. No point doing all that work if its not going to be used!
- new Float:X,Float:Y,Float:Z,Float:A;
- new text = strval(inputtext); //Strval isn't really the best way to go, but it will do. sscanf is much better!
- GetPlayerPos(playerid,X,Y,Z);
- GetPlayerFacingAngle(playerid,A);
- if(text < 400 || text > 611)
- {
- return SendClientMessage(playerid, 0x00FF00FF, "Error: Invalid model ID.");
- }
- CreateVehicle(text, X,Y,Z+2,A, 126, 126, -1);
- return SendClientMessage(playerid, 0x00FF00FF, "Vehicle created successfully.");
- }
- else
- {
- return SendClientMessage(playerid, 0x00FF00FF, "Selection canceled.");
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment