Jump to content

Gang system problem


FWCentral

Recommended Posts

Nah it doesn't save the gang, It just saves the element data in the players account then when they reconnect it sets the element data again and when they open the gang gui it goes through the players and checks what players have the element data same as that player and puts the player names in a gridlist it seems to work apart from the create error.

Link to comment

ok so i tried making the creategang command using SQL, i created a database like this :

  
executeSQLCreateTable ( "Gangs", "Gangname TEXT, Leader TEXT" ) 
  

This worked fine

then for the create command:

  
function creategang(source, commandName, gangname) 
isgang = getElementData(source,"gang") 
if isgang then 
outputChatBox("Your allready in a gang /quitgang first", source, 255, 0, 0) 
else 
sourcename = getPlayerName ( source ) 
local gang = executeSQLSelect ( "Gangs", "Gangname", "Gangname = '" .. gangname .. "'" ) 
    if gang then 
    outputChatBox("This Gang is allready created!", source, 255, 0, 0) 
    else 
local money = getPlayerMoney(source) 
    if (money > 3000) then 
    takePlayerMoney(source, tonumber(3000)) 
    executeSQLInsert ( "Gangs", "'Gangname'", "'Leader'", "'".. gangname .."'", "'"..sourcename.."'" ) 
    outputChatBox("You have created the "..gangname..".", source, 0, 255, 0) 
    setElementData(source, "gang", gangname) 
    setElementData(source, "Rank", "Leader") 
end 
end 
end 
end 
addCommandHandler("creategang", creategang, gangname) 
  

It just says to me the gang is already created when it isn't and no errors in the debug either.

This is my first time using this SQL please go easy ;)

Link to comment
function creategang(source, commandName, gangname) 
isgang = getElementData(source,"gang") 
if isgang then 
outputChatBox("Your allready in a gang /quitgang first", source, 255, 0, 0) 
else 
sourcename = getPlayerName ( source ) 
local gang = executeSQLSelect ( "Gangs", "Gangname", "Gangname = '" .. gangname .. "'" ) 
    if gang and #gang > 0 then 
    outputChatBox("This Gang is allready created!", source, 255, 0, 0) 
    else 
local money = getPlayerMoney(source) 
    if (money > 3000) then 
    takePlayerMoney(source, tonumber(3000)) 
    executeSQLInsert ( "Gangs", "'Gangname','Leader'", "'".. gangname .."', '"..sourcename.."'" ) 
    outputChatBox("You have created the "..gangname..".", source, 0, 255, 0) 
    setElementData(source, "gang", gangname) 
    setElementData(source, "Rank", "Leader") 
end 
end 
end 
end 
addCommandHandler("creategang", creategang, gangname) 
  
  
  

Link to comment

Thanks JR10 but i got an error:

error is on this line,

executeSQLInsert ( "Gangs", "'Gangname','Leader'", "'".. gangname .."', '"..sourcename.."'" )

if i type /creategang FWCentral it says DB Query failed table Gangs has no column named FWCentral

and if i type /creategang FWC i get the error Query failed table Gangs has no column named FWC

It still takes the players money and sets the Element Data correctly.

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