zombienation Posted January 13, 2012 Share Posted January 13, 2012 (edited) hello, i have found a small bug in a vehicle panel, the script says there is a limit of 2 spawns, but the limit dont work the same script file have something that blocks rhino and hunter, that works, but the limit not, is there somebody who could tell me how i can fix this please?? thank you ----------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- ---------------------------------------------------------------- ----------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- ------------------SCRIPT BY TAALASMAA (C) DO NOT EDIT THIS WITHOUT PERMISSIONS----- ----------------------------------------------------------------------------------- disallowedVehicle = {{425},{432}} -- RHINO AND HUNTER -- ----------------------------------------- ---------------------------------------- --------CARSPAWN LIMIT------------------ carSpawnLimit = {{"2"}} -- can be changed -- NOT IN USE IN 0.1!!!!!! --- ---------------------------------------- ---------------------------------------- -------------------------- ------------------------- function spawnAcar(carID) for i,v in ipairs (disallowedVehicle) do if (v[1] == carID) then outputChatBox("This is disallowed vehicle!",source,255,0,0) return false end end playerX,playerY,playerZ = getElementPosition(source) vehicle = createVehicle(carID,playerX + 2,playerY +2, playerZ) end addEvent("onPlayerWantToSpawn",true); addEventHandler("onPlayerWantToSpawn",getRootElement(),spawnAcar) ----------------------------------------------------------------------------------- ----------------------------------------------------------------------------------- Edited January 13, 2012 by Guest Link to comment
Castillo Posted January 13, 2012 Share Posted January 13, 2012 It doesn't work because it was never implemented, he never finished the script. Link to comment
zombienation Posted January 13, 2012 Author Share Posted January 13, 2012 It doesn't work because it was never implemented, he never finished the script. hm that makes sence do you know how i can finnish it? Link to comment
12p Posted January 13, 2012 Share Posted January 13, 2012 Humm... Guessing a lot, writing a lot, spending a lot of time... What stops you from doing it? Link to comment
Scooby Posted January 13, 2012 Share Posted January 13, 2012 theres no check for the amount of times u spawn a car in your script. u can easily make ur own counter tho. try this.... local root = getRootElement() local disallowedVehicle = { [425]=true, [432]=true } -- add any other vehicle ID's here that u need to disallow local vehicleSpawnCounter = {} local vehicleSpawnLimit = 2 -- set to 2 vehicle spawns, change as required addEvent("onPlayerWantToSpawn",true) function spawnMyVehicle(carID) if disallowedVehicle[carID] then outputChatBox("This is disallowed vehicle!",source,255,0,0) else if carSpawnCounter[source] <= vehicleSpawnLimit then local x,y,z = getElementPosition(source) local vehicle = createVehicle(carID,x + 2,y +2, z) vehicleSpawnCounter[source] = vehicleSpawnCounter[source] + 1 else outputChatBox("Vehicle Spawn Limit Reached!",source,255,0,0) end end end addEventHandler("onPlayerWantToSpawn",root,spawnMyVehicle) function playerJoined() vehicleSpawnCounter[source] = 0 end addEventHandler( "onPlayerJoin", root, playerJoined ) function playerQuit() vehicleSpawnCounter[source] = nil end addEventHandler( "onPlayerQuit", root, playerQuit ) im not familiar with your script and i dont know what gamemode your using so i havent tested this. try it out and let me know if theres any problems. Link to comment
zombienation Posted January 13, 2012 Author Share Posted January 13, 2012 theres no check for the amount of times u spawn a car in your script.u can easily make ur own counter tho. try this.... local root = getRootElement() local disallowedVehicle = { [425]=true, [432]=true } -- add any other vehicle ID's here that u need to disallow local vehicleSpawnCounter = {} local vehicleSpawnLimit = 2 -- set to 2 vehicle spawns, change as required addEvent("onPlayerWantToSpawn",true) function spawnMyVehicle(carID) if disallowedVehicle[carID] then outputChatBox("This is disallowed vehicle!",source,255,0,0) else if carSpawnCounter[source] <= vehicleSpawnLimit then local x,y,z = getElementPosition(source) local vehicle = createVehicle(carID,x + 2,y +2, z) vehicleSpawnCounter[source] = vehicleSpawnCounter[source] + 1 else outputChatBox("Vehicle Spawn Limit Reached!",source,255,0,0) end end end addEventHandler ("onPlayerWantToSpawn",root,spawnMyVehicle) function playerJoined() vehicleSpawnCounter[source] = 0 end addEventHandler( "onPlayerJoin", root, playerJoined ) function playerQuit() vehicleSpawnCounter[source] = nil end addEventHandler( "onPlayerQuit", root, playerQuit ) im not familiar with your script and i dont know what gamemode your using so i havent tested this. try it out and let me know if theres any problems. Thanks man. i will test this right after work and let u know about it Link to comment
zombienation Posted January 13, 2012 Author Share Posted January 13, 2012 hey scooby, i'm testing your script, i have one error when i try to spawn a car, ERROR: veh\vehiclepanel_s.lua:11: attempt to index global 'carSpawnCounter' (a nil value) it wont spawn a car Link to comment
Scooby Posted January 14, 2012 Share Posted January 14, 2012 sorry my bad, carSpawnCounter should read vehicleSpawnCounter, i changed it after writing it since i thought u might be allowing vehicles other than cars. the line should read: if vehicleSpawnCounter[source] <= vehicleSpawnLimit then sorry about that. Link to comment
zombienation Posted January 14, 2012 Author Share Posted January 14, 2012 sorry my bad, carSpawnCounter should read vehicleSpawnCounter, i changed it after writing it since i thought u might be allowing vehicles other than cars. the line should read: if vehicleSpawnCounter[source] <= vehicleSpawnLimit then sorry about that. No problem thx man i will test it after work 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