Jump to content

Peds storted in database. Give some a weapon


Recommended Posts

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
  
  
    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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...