Phoenix-Roleplay Posted July 14, 2012 Author Share Posted July 14, 2012 All the same issues, it seems the only one that would work was Cadus but it didn't show the successful spawn message. Link to comment
Jaysds1 Posted July 14, 2012 Share Posted July 14, 2012 Sorry, I found my mistake I edited the code again Link to comment
Phoenix-Roleplay Posted July 14, 2012 Author Share Posted July 14, 2012 Ok! Yours seems to spawn the vehicle and display the message, but fails to display any messages if you enter a incorrect vehicle id, but will display it if you input a invalid name strange.. Link to comment
Phoenix-Roleplay Posted July 14, 2012 Author Share Posted July 14, 2012 Now fix it! all joking aside, I'm trying to fix it myself EDIT: Revised it a little bit and I fixed it! For anyone wanting to use it: function createVehicleCommand ( thePlayer, commandName, carName ) if not carName then outputChatBox("Syntax: /v [vehicle id/model]", thePlayer, 255, 0, 0) return end local x, y, z = getElementPosition ( thePlayer ) local carModel = tonumber ( carName ) if (type(carModel) == "number") then if (carModel < 400 or carModel > 611) then outputChatBox("Invalid vehicle ID!", thePlayer, 255, 0, 0) return else createVehicle(carModel, x + 5, y, z) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (#" .. carModel .. ") was spawned with an ID of " .. vehicles.id, thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end else local carModel = getVehicleModelFromName(carName) if (not carModel) then outputChatBox("Invalid vehicle name!", thePlayer, 255, 0, 0) return else createVehicle(carModel, x + 5, y, z) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (#" .. carModel .. ") was spawned with and ID of " .. vehicles.id, thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end end end addCommandHandler ( "v", createVehicleCommand ) Link to comment
Cadu12 Posted July 14, 2012 Share Posted July 14, 2012 (edited) function createVehicleCommand ( thePlayer, commandName, carName ) local x, y, z = getElementPosition ( thePlayer ) if (type(tonumber(carName)) == "number") then if tonumber(carName) > 400 and tonumber(carName) < 611 then outputChatBox("Invalid Vehicle", player, 255, 0, 0) else local veh = createVehicle(carName, x+5, y, z) outputChatBox("Your " .. getVehicleName(veh) .. " (#" .. tonumber(carName) .. ") was spawned with an ID of " .. vehicles.id, player, 0, 255, 0) vehicles.id = vehicles.id+1 end else local carModel = getVehicleModelFromName(carName) if not carModel then outputChatBox("That is not a valid car name") else createVehicle(carModel, x+5, y, z) outputChatBox("Your " .. getVehicleName(carModel) .. " (#" .. carModel .. ") was spawned with and ID of " .. vehicles.id, player, 0, 255, 0) vehicles.id = vehicles.id+1 end end end addCommandHandler("v", createVehicleCommand) Edited July 14, 2012 by Guest Link to comment
Phoenix-Roleplay Posted July 14, 2012 Author Share Posted July 14, 2012 Your slightly late, already revised it and it works both ways. Also, you forgot a tag there buddy! function createVehicleCommand ( thePlayer, commandName, carName ) local currVehicle = getPedOccupiedVehicle(thePlayer) if currVehicle then outputChatBox("You already are in a vehicle! Use /cv to change your vehicle!", thePlayer, 255, 0, 0) return end if commandName == "v" then if not carName then outputChatBox("Syntax: /" .. commandName .. " [vehicle id/model]", thePlayer, 255, 0, 0) return end local x, y, z = getElementPosition ( thePlayer ) local carModel = tonumber ( carName ) if (type(carModel) == "number") then if (carModel < 400 or carModel > 611) then outputChatBox("Invalid vehicle ID!", thePlayer, 255, 0, 0) return else createVehicle(carModel, x+5, y, z+2) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end else local carModel = getVehicleModelFromName(carName) if carName == "random" then carModel = math.random(400,611) createVehicle(carModel, x+5, y, z+2) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end if (not carModel) then outputChatBox("Invalid vehicle name!", thePlayer, 255, 0, 0) return else createVehicle(carModel, x+5, y, z+2) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end end elseif commandName == "vx" then if not carName then outputChatBox("Syntax: /" .. commandName .. " [vehicle id/model]", thePlayer, 255, 0, 0) return end local x, y, z = getElementPosition ( thePlayer ) local carModel = tonumber ( carName ) local theVeh if (type(carModel) == "number") then if (carModel < 400 or carModel > 611) then outputChatBox("Invalid vehicle ID!", thePlayer, 255, 0, 0) return else theVeh = createVehicle(carModel, x, y, z+2) warpPedIntoVehicle(thePlayer, theVeh) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end else local carModel = getVehicleModelFromName(carName) if carName == "random" then carModel = math.random(400,611) theVeh = createVehicle(carModel, x, y, z+2) warpPedIntoVehicle(thePlayer, theVeh) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end if (not carModel) then outputChatBox("Invalid vehicle name!", thePlayer, 255, 0, 0) return else theVeh = createVehicle(carModel, x, y, z+2) warpPedIntoVehicle(thePlayer, theVeh) outputChatBox("Your " .. getVehicleNameFromModel(carModel) .. " (Model: " .. carModel .. ") (ID: " .. vehicles.id .. ") was spawned!", thePlayer, 0, 255, 0) vehicles.id = (vehicles.id + 1) return end end end end addCommandHandler("v", createVehicleCommand) addCommandHandler("vx", createVehicleCommand) Link to comment
Cadu12 Posted July 14, 2012 Share Posted July 14, 2012 Oh, i didn't know. You're welcome Link to comment
Phoenix-Roleplay Posted July 14, 2012 Author Share Posted July 14, 2012 Haha thanks buddy. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now