Sasu Posted March 25, 2013 Share Posted March 25, 2013 Server: exports.scoreboard:addScoreboardColumn("Gang") function check() local account = getPlayerAccount(source) if getAccountData(account, "Gang") then setElementData(source, "Gang", getAccountData(account, "Gang")) else setElementData(source, "Gang", None) end end addEventHandler("onPlayerLogin", root, check) function crearTabla() check = executeSQLQuery("CREATE TABLE IF NOT EXISTS gangSystem(gangs TEXT, members TEXT, infoGang TEXT)") if check then outputDebugString("Creando tabla 'gangSystem'... Se ha creado correctamente") else outputDebugString("Ha ocurrido un error al crear las tablas") end end addEventHandler("onResourceStart", resourceRoot, crearTabla) function crearGang(thePlayer, gangName, liderName) liderText = "lider" infoGang = "Bienvenido al gang "..gangName.."." crear = executeSQLQuery("INSERT INTO gangSystem(gangs, members, infoGang) VALUES(?,?=?=?,?)", gangName, liderText, gangName, liderName, infoGang) local account = getPlayerAccount(thePlayer) setAccountData(account, "Gang", tostring(gangName)) setElementData(thePlayer, "Gang", tostring(gangName)) if crear then outputDebugString("Se ha creado un gang con nombre: "..gangName.." el cual el lider es "..liderName) end end addEvent("onCreateGang", true) addEventHandler("onCreateGang", resourceRoot, crearGang) function obtenerlider(playerName, info) if (not getElementData(source, "Gang") == "None") then local gangName = getElementData(source, "Gang") info = executeSQLQuery("SELECT infoGang FROM gangSystem WHERE ?", gangName ) triggerClientEvent("gangLider", source, playerName, info) end end addEventHandler("onPlayerLogin", root, obtenerlider) Client(a part): function crearGang(thePlayer, gangName, liderName) gangName = guiGetText(gangEdit) liderName = getPlayerName(localPlayer) if gangName then triggerServerEvent("onCreateGang", getRootElement(), getLocalPlayer(), gangName, liderName) end end function miembros(playerName, info) local row = guiGridListAddRow ( playerGangList ) guiGridListSetItemText ( playerGangList, row, nameColumn, getPlayerName ( playerName ), false, false ) guiSetText(infoMemo, info) end addEvent("gangLider", true) addEventHandler("gangLider", root, miembros) I want to save the info gang and set text in the infoMemo. Also I want to create a row with the leader but I cant. Can you help me? Link to comment
DNL291 Posted March 25, 2013 Share Posted March 25, 2013 The parameters of the "onPlayerLogin" event are: thePreviousAccount, theCurrentAccount, autologin. Link to comment
Sasu Posted March 28, 2013 Author Share Posted March 28, 2013 Why in the memo appear: "table: 04D24608"? Server: function obtenerInfo(thePlayer) local gang = getElementData(thePlayer, "Gang") local infoGang = executeSQLQuery ( "SELECT infoGang FROM gangsName WHERE Nombre = ?", gangName ) triggerClientEvent("onOpenInfo", getRootElement(), tostring(infoGang)) end addEvent("onOpen", true) addEventHandler("onOpen", root, obtenerInfo) Client: function abrir3(infoGang) guiSetVisible(infoWindow, true) guiSetVisible(gangWindow, false) guiSetText(infoMemo, tostring(infoGang)) end addEvent("onOpenInfo", true) addEventHandler("onOpenInfo", root, abrir3) function abrir2() triggerServerEvent("onOpen", localPlayer, localPlayer) end Link to comment
PaiN^ Posted March 28, 2013 Share Posted March 28, 2013 Not tested ! -- Server -- function obtenerInfo( ) local gang = getElementData( source, "Gang") local infoGang = executeSQLQuery ( "SELECT infoGang FROM gangsName WHERE Nombre = ?", gangName ) triggerClientEvent( "onOpenInfo", source, unpack(infoGang)) end addEvent("onOpen", true) addEventHandler("onOpen", root, obtenerInfo) -- Client -- function abrir3( infoGang ) guiSetVisible(infoWindow, true) guiSetVisible(gangWindow, false) guiSetText(infoMemo, tostring(infoGang)) end addEvent("onOpenInfo", true) addEventHandler("onOpenInfo", root, abrir3) function abrir2() triggerServerEvent("onOpen", localPlayer ) end Link to comment
TAPL Posted March 28, 2013 Share Posted March 28, 2013 Not tested !-- Server -- function obtenerInfo( ) local gang = getElementData( source, "Gang") local infoGang = executeSQLQuery ( "SELECT infoGang FROM gangsName WHERE Nombre = ?", gangName ) triggerClientEvent( "onOpenInfo", source, unpack(infoGang)) end addEvent("onOpen", true) addEventHandler("onOpen", root, obtenerInfo) gangName not defined. Wrong trigger, it will be triggered to everyone. (infoWindow will open for everyone) Link to comment
Sasu Posted March 28, 2013 Author Share Posted March 28, 2013 Not tested !-- Server -- function obtenerInfo( ) local gang = getElementData( source, "Gang") local infoGang = executeSQLQuery ( "SELECT infoGang FROM gangsName WHERE Nombre = ?", gangName ) triggerClientEvent( "onOpenInfo", source, unpack(infoGang)) end addEvent("onOpen", true) addEventHandler("onOpen", root, obtenerInfo) gangName not defined. Wrong trigger, it will be triggered to everyone. (infoWindow will open for everyone) Server: function obtenerInfo( source ) local gangName = getElementData( source, "Gang") local infoGang = executeSQLQuery ( "SELECT infoGang FROM gangsName WHERE Nombre = ?", gangName ) triggerClientEvent( "onOpenInfo", source, unpack(infoGang)) end addEvent("onOpen", true) addEventHandler("onOpen", root, obtenerInfo) Client: function abrir3( infoGang ) guiSetVisible(infoWindow, true) guiSetVisible(gangWindow, false) guiSetText(infoMemo, tostring(infoGang)) end addEvent("onOpenInfo", true) addEventHandler("onOpenInfo", root, abrir3) function abrir2(source) triggerServerEvent("onOpen", getLocalPlayer(), getLocalPlayer() ) end When I open the memo appear this: table: 305AD600 Why? Link to comment
TAPL Posted March 28, 2013 Share Posted March 28, 2013 triggerClientEvent(source, "onOpenInfo", source, infoGang[1]["infoGang"]) 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