Kaos Posted August 20, 2016 Share Posted August 20, 2016 Hello i've got a RPG gamemode , actually , a RPG server with all resources , it working great, but still got some problems , or i did not understand this gamemode , or i must make something. So here's the problem's : I do not know how to put player's on the official gang team's (example: Army/SWAT/Gouvern) , what should i do , is a command/script who don't work, where should i check. And the second problem is with official gang team's vehicle's i do not know the command to set them / spawn them, or is a problem with the script? Please help me,i've searching for a answer like 2 day's ago,and i can not solve it.I would like to hear all the advice/answer's,thank you Link to comment
Gravestone Posted August 20, 2016 Share Posted August 20, 2016 We know that script doesn't work but we don't know why and in what way it doesn't work. We'll never know that unless you provide us with the part of the code. Link to comment
G-Stefan Posted August 20, 2016 Share Posted August 20, 2016 Posting the gm name will be helpful. Second,tell me what kind of databases the gm uses? Link to comment
Kaos Posted August 21, 2016 Author Share Posted August 21, 2016 We know that script doesn't work but we don't know why and in what way it doesn't work. We'll never know that unless you provide us with the part of the code. accountArray = { ["kaos"] = true, ["conner"] = true, } validGroups = {} playerCache = {} addEvent ( "onPlayerGroupAdd", true ) addEvent ( "onPlayerGroupRemove", true ) -- Debug mode toggle. verbose = false -- End of debug mode toggle. outputDebugStringMTA = outputDebugString function outputDebugString(...) if verbose then outputDebugStringMTA(unpack(arg)) end end ------------------------------------------------------------ Backend functions -------------------------------------------- function validateGroups(valid) local groupArray = executeSQLQuery("SELECT * FROM validgroups") local groupConcatArray = {} for k,v in ipairs(groupArray) do local name = v.groupname validGroups[name] = true table.insert(groupConcatArray, name) end outputDebugString("WSSacl loaded - Valid groups: " .. table.concat(groupConcatArray, ", ")) end function cachePlayer(player) local account = getPlayerAccount(player) if account then local accountName = getAccountName(account) local groupString = "" local groups = executeSQLQuery("SELECT * FROM `usergroups` WHERE `accountname` = ?", accountName) if groups and #groups == 1 then groupString = groups[1]['groups'] outputDebugString("Player " .. getPlayerName(player) .. "'s data got fetched : " .. groupString .. ".") elseif groups then outputDebugString("Player " .. getPlayerName(player) .. "'s groups could not be fetched : more than one record for the player. Number of rows:" .. #groups .. ".") else outputDebugString("Player " .. getPlayerName(player) .. "'s groups could not be fetched : error in database query.") end playerCache[player] = {} local groupArray = fromJSON(groupString) or {} outputDebugString("Player " .. getPlayerName(player) .. " is a member of " .. #groupArray .. " groups. (" .. groupString .. ")") for i,v in ipairs(groupArray) do if validGroups[v] then playerCache[player][v] = true outputDebugString("Group " .. v .. " added to player " .. getPlayerName(player) .. "'s cache.") else outputDebugString("Group " .. v .. " could not be added to player " .. getPlayerName(player) .. "'s cache: Invalid group.") end end return true else outputDebugString("Failed caching player information for player " .. getPlayerName(player) .. " : No account set.") return false end end function uncachePlayer(player) if player then if playerCache[player] then playerCache[player] = nil end end return true end ------------------------------------------------------------ Group functions --------------------------------------------- function createGroup(group) if group and tostring(group) then group = tostring(group) local groupsWithName = executeSQLQuery("SELECT * FROM validgroups WHERE groupname = ?", group) if groupsWithName and #groupsWithName == 0 then local query = executeSQLQuery("INSERT INTO `validgroups`(`groupname`) VALUES (?)", group) if query then validGroups[group] = true outputDebugString("WSSacl loaded new group : " .. group) return true end end end return false end function deleteGroup(group) if group and tostring(group) then group = tostring(group) local groupsWithName = executeSQLQuery("SELECT * FROM validgroups WHERE groupname = ?", group) if groupsWithName and #groupsWithName == 1 and validGroups[group] then local query = executeSQLQuery("DELETE FROM `validgroups` WHERE groupname = ?", group) if query then for i,v in ipairs(getGroupAccounts(group)) do removeAccountFromGroup(v, group) end validGroups[group] = nil outputDebugString("WSSacl unloaded group : " .. group) return true end end end return false end ------------------------------------------------------------- Functions by group ---------------------------------------------- function getGroupAccounts(group) if validGroups[group] then local groupAccounts = executeSQLQuery("SELECT * FROM `usergroups` WHERE groups LIKE ?", "%" .. group .. "%") if groupAccounts then local returnTable = {} for i,v in ipairs(groupAccounts) do local username = v.accountname local account = getAccount(username) if account then table.insert(returnTable, account) end end return returnTable else outputDebugString("WSSacl - getGroupAccounts() failed - Database query failed.") return false end else outputDebugString("WSSacl - getGroupAccounts() failed - Invalid group (" .. tostring(group) .. ") specified.") return false end end function getPlayersInGroup(group) if group and validGroups[group] then local returnTable = {} for i,v in pairs(playerCache) do if v[group] then table.insert(returnTable, i) end end return returnTable else outputDebugString("Failed getting players in group " ..tostring(group) .. " : Invalid group name.") return false end end ------------------------------------------------------------- Functions by player --------------------------------------------- function isPlayerInGroup(player,group) if player and group and tostring(group) then if isElement(player) and getElementType(player) == "player" then if not playerCache[player] then cachePlayer(player) end if playerCache[player][group] then return true else return false end else outputDebugString("*WSSacl* isPlayerInGroup (WSSacl) invalid variables (player, group).") end else outputDebugString("*WSSacl* isPlayerInGroup (WSSacl) variables not passed (player, group).") end end function getPlayerGroups(player) if not playerCache[player] then cachePlayer(player) end local returnTable = {} for group, value in pairs(playerCache[player]) do if value then table.insert(returnTable, group) end end return returnTable end ------------------------------------------------------------ Functions by account -------------------------------------------- function getAccountGroups(account) if account and getAccountName(account) then local query = executeSQLQuery("SELECT groups FROM usergroups WHERE accountname = ?", getAccountName(account)) if query then if query[1] then local datString = query[1]['groups'] return fromJSON(datString) or {} else return {} end else return false end else return false end end function isAccountInGroup(account, group) if account and group and getAccountName(account) and validGroups[group] then local groups = getAccountGroups(account) if groups then for i,v in ipairs(groups) do if v == group then return true end end return false else return false end else return false end end function setAccountGroups(account, groups) if account and getAccountName(account) and groups and type(groups) == "table" then local username = getAccountName(account) local groupString = toJSON(groups) local query = executeSQLQuery("UPDATE usergroups SET groups = ? WHERE accountname = ?", groupString, username) if query then return true else local query2 = executeSQLQuery("INSERT INTO usergroups(accountname, groups) VALUES(?,?)", username, groupString) if query2 then return true end end end return false end function addAccountToGroup(account, group) Link to comment
Kaos Posted August 21, 2016 Author Share Posted August 21, 2016 Posting the gm name will be helpful.Second,tell me what kind of databases the gm uses? Salut Stefan , name of the gamemode is WSS:RPG (why so serious),and i really dont know how to find what type of databases gm uses.. Link to comment
Gravestone Posted August 21, 2016 Share Posted August 21, 2016 I meant the part of code in which you're facing the error... Link to comment
G-Stefan Posted August 21, 2016 Share Posted August 21, 2016 To find out the commands go thru all scripts and find addCommandHandler-s.The command will be there in the first argument Ex: addCommandHandler("command",function) Then try to use the command and if is not working post the entire function To check errors give yourself admin in ACL.xml then type in console debugscript 3 If errors appears make a screenshot and post it here Link to comment
Kaos Posted August 21, 2016 Author Share Posted August 21, 2016 To find out the commands go thru all scripts and find addCommandHandler-s.The command will be there in the first argumentEx: addCommandHandler("command",function) Then try to use the command and if is not working post the entire function To check errors give yourself admin in ACL.xml then type in console debugscript 3 If errors appears make a screenshot and post it here I search on all scriptes/resource's but couldn't find the addCommandHandler-s.lua. and i found command-s.lua. Here's the command-s.lua -- Last Login addCommandHandler("lastlogin", function(typer, command, logger) if logger and logger ~= "" then if getAccount(logger) then local lastlogin = getAccountData(getAccount(logger), "lastlogin") exports.WSScommands:sendMessage("Account: ".. logger .." last logged in on ".. lastlogin, 240, 240, 4, typer) --elseif getPlayerFromName(logger) then --local lastlogin = getAccountData(getPlayerAccount(getPlayerFromName(logger)), "lastlogin") --exports.WSScommands:sendMessage("Player: ".. logger .." last logged in on ".. lastlogin, 240, 240, 4, typer) end else exports.WSScommands:sendMessage("Usage: /seen [account]", 240, 240, 4, typer) end end ) addCommandHandler("command",function) Here's the screenshot with the errors what appears when i typed debugscript 3. 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