FWCentral Posted September 18, 2011 Share Posted September 18, 2011 I have made a gang system using element data and the gang saves in the players account and rejoins the player on login but the problem is if a player type /creategang Name then it will put them in the gang even if its allready been created and they are not the leader. Link to comment
Castillo Posted September 18, 2011 Share Posted September 18, 2011 So, your problem is that they can create a gang that already exists, did I get it right? Link to comment
FWCentral Posted September 18, 2011 Author Share Posted September 18, 2011 Yeah that is correct, but the create script only simply checks the player money, then it takes the player money then sets the players element data into the chosen gang but if the gang is allready created it still puts the player in the gang and i dont know how to stop this. Link to comment
Castillo Posted September 18, 2011 Share Posted September 18, 2011 Well, where do you save the gangs? you have to save them somewhere, right? Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 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
qaisjp Posted September 19, 2011 Share Posted September 19, 2011 bad scripting mehod! Save into SQLite or mysql or xml the gang names, and then save accoutn data of gang name. and check whn the gang is already made Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 So keep my method of loading and saving but change the creation of gangs to SQL ok ill try this. Link to comment
Baseplate Posted September 19, 2011 Share Posted September 19, 2011 Thnxs guys we'll test it then if we have any errors we will post it over here Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 umm how do i delete element data from a player?? Link to comment
JR10 Posted September 19, 2011 Share Posted September 19, 2011 So keep my method of loading and saving but change the creation of gangs to SQL ok ill try this. Method of creation, saving, loading should be the same. EDIT: removeElementData Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 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
JR10 Posted September 19, 2011 Share Posted September 19, 2011 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
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 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
JR10 Posted September 19, 2011 Share Posted September 19, 2011 executeSQLInsert ( "Gangs", "'".. gangname .."', '"..sourcename.."'" ) Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 same line error say Gangs has 5 columns but 2 values were supplied, i don't have any other SQL scripts so why it say there are 5? Thanks again JR10. Link to comment
JR10 Posted September 19, 2011 Share Posted September 19, 2011 May you PM me or post the full code? Link to comment
FWCentral Posted September 19, 2011 Author Share Posted September 19, 2011 Thanks JR10 Problem solved! Awesome 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