benwilkins Posted June 19, 2013 Share Posted June 19, 2013 Hey, I have some code to generate the peds from the database. Everytime i create a ped, it makes a unique field to the ped called "id". When I get the results from the database to make the peds in game, I need a way to do like. (if "id" is between 120 and 180, then set those peds to have an M4) but not the other peds. Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 Post what you have tried, or your code. Link to comment
benwilkins Posted June 19, 2013 Author Share Posted June 19, 2013 local result = mysql:query("SELECT id, x, y, z, dimension, interior, rotation, skin FROM peds") while true do local row = exports.mysql:fetch_assoc(result) if not (row) then break end local id = tonumber(row["id"]) local x = tonumber(row["x"]) local y = tonumber(row["y"]) local z = tonumber(row["z"]) local dimension = tonumber(row["dimension"]) local interior = tonumber(row["interior"]) local rotation = tonumber(row["rotation"]) local skin = tonumber(row["skin"]) local ped = createPed(skin, x, y, z) setPedRotation(ped, rotation) setElementDimension(ped, dimension) setElementInterior(ped, interior) if(id BETWEEN 120 AND 180) then giveWeapon( ped, 31, 1, true ) end Thats why I have tried so far Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 if(id BETWEEN 120 AND 180) then Wrong, should be: if ( id >= 120 and id < 181 ) then Link to comment
benwilkins Posted June 19, 2013 Author Share Posted June 19, 2013 That kind of works. When I restart the resource, he spawns with a weapon, but then after a second the weapon disappears. Link to comment
Castillo Posted June 19, 2013 Share Posted June 19, 2013 Why would the weapon dissapear? maybe you got a script doing that? 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