Jump to content

Problem with createTeam.


xeon17

Recommended Posts

Hello,

I have a problem with the createTeam function which doesn't work properly in my code. The problem is, only one team is created but there are a few more teams saved in the database but only the first team is being created and i would like to know why?

This is a screenshot of the database table where the teams are stored. The first team which in this case is Team1 is being created but the others not.

My code:

function Gang:loadGangs () 
     
    Database:getConnection():query(function(result) 
    local result = result:poll(0) 
     
    local name   = result[1].Name 
    local r      = result[1].r 
    local g      = result[1].g 
    local b      = result[1].g 
    local leader = result[1].Leader 
    local tag    = result[1].Tag 
    local XP     = result[1].XP 
     
    self.Gang = Team(name, r, g, b) 
    self.Gang:setData('name',name) 
    self.Gang:setData('xp',XP) 
    self.Gang:setData('r',r) 
    self.Gang:setData('g',g) 
    self.Gang:setData('b',b) 
    self.Gang:setData('leader',leader) 
     
    for _,player in pairs (getElementsByType('player')) do 
        if (self: getPlayerGang(player) == name) then 
            self: setPlayerGang(player, name, self: getPlayerLevel(player)) 
        end 
    end 
     
    outputDebugString('Gangs: Gangs succesfully loaded!') 
    
    end,"SELECT * FROM Gangs") 
end 

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