FuriouZ Posted May 4, 2014 Share Posted May 4, 2014 Hello all! I know i already have posted this, but i didn't got a answer Well, the problem is that i can't spawn a vehicle, line 15 says " attempt to compare nil with number " Server: --# Create Vehicle addEvent("onPlayerRequest:Vehicle",true); addEventHandler("onPlayerRequest:Vehicle",getRootElement(), function(carID) local disallowedVehicles = { {425}, {432} } local vehicleSpawnCounter = {} local vehicleSpawnLimit = 2 if getElementType(source) == "player" then for i,v in ipairs (disallowedVehicles) do if (v[1] == carID) then outputChatBox("This is disallowed vehicle!",source,255,0,0) return false end end if vehicleSpawnCounter[source] < vehicleSpawnLimit then local playerX,playerY,playerZ = getElementPosition(source) vehicle = createVehicle(carID,playerX + 2,playerY +2, playerZ) vehicleSpawnCounter[source] = vehicleSpawnCounter[source] + 1 else outputChatBox("Vehicle Spawn Limit Reached!", source,255,0,0) end end end) Thanks ! Link to comment
LonelyRoad Posted May 4, 2014 Share Posted May 4, 2014 Your script assumes that an entry in the table 'vehicleSpawnCounter' exists for 'source'...you need to separate that check from line 15 and do something like: local counter = vehicleSpawnCounter[source] or 0 An equation like that should also really have brackets ( ) round it, so: if (vehicleSpawnCounter[source] < vehicleSpawnLimit) then 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