Jump to content

Peds storted in database. Give some a weapon


Recommended Posts

Posted

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.

Posted

Post what you have tried, or your code.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
  
  
    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

Posted
if(id BETWEEN 120 AND 180) then 

Wrong, should be:

if ( id >= 120 and id < 181 ) then 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Why would the weapon dissapear? maybe you got a script doing that?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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