Jump to content

spawn problem.


ramzi

Recommended Posts

Guys,i have bought this spawn menu but the scoreboard doesnt show teams,idk why...this is the error msg:

[2014-12-23 11:52:57] WARNING: RGlogin\spawn_server.lua:81: Bad argument @ 'getTeamColor' [Expected team at argument 1, got boolean]

[2014-12-23 11:52:57] WARNING: RGlogin\spawn_server.lua:85: Bad argument @ 'createBlipAttachedTo' [Expected number at argument 4, got boolean]

[2014-12-23 11:52:57] WARNING: RGlogin\spawn_server.lua:86: Bad argument @ 'setElementVisibleTo' [Expected element at argument 1, got boolean]

[2014-12-23 11:52:57] WARNING: RGlogin\spawn_server.lua:103: Bad argument @ 'getResourceState' [Expected resource-data at argument 1, got boolean]

and this is the lua code:

armorTeams = {["Admin"] = true,["Macedonian Gaming Event Menagers"] = true,["None"] = true,["Al Qeada"] = true,["S.W.A.T."] = true} 
  
local isMayhemEnabled = false 
  
local spawnFreeGroups = "fd,fdn,nf,nfr,unionsoldier,confedsoldier,sahpmember,sahper,fbcmember,usocmember,eimember" 
local free1 = split(spawnFreeGroups, ",") 
local free2 = {} 
for i,v in ipairs(free1) do 
    free2[v] = true 
end 
  
function initializeSpawns (resourceStarted) 
    if getResourceName(resourceStarted) == "MGlogin" or getResourceName(resourceStarted) == "SARGspawnmap" then 
        startResource(getResourceFromName("MGspawnmap")) 
        local xml = xmlLoadFile(":MGspawnmap/spawns.xml")             -- open the XML file 
        local cityNodes = xmlNodeGetChildren(xml)       -- get all child nodes of the root node () 
        local cities = {}                             -- create a new global variable to store the welcome messages 
        for i,node in ipairs(cityNodes) do 
            local classnodes = xmlNodeGetChildren(node) 
            for i2,node2 in ipairs(classnodes) do 
                local name = xmlNodeGetAttribute(node2, "name") 
                local r = xmlNodeGetAttribute(node2, "r") 
                local g = xmlNodeGetAttribute(node2, "g") 
                local b = xmlNodeGetAttribute(node2, "b") 
                if not getTeamFromName(name) then 
                    createTeam( name , r , g , b) 
                end 
            end 
        end 
        xmlUnloadFile(xml) 
    end 
end 
addEventHandler("onResourceStart", root, initializeSpawns) 
  
function logAllOut() 
    local players = getElementsByType ( "player" ) 
    for k, player in ipairs(players) do 
        account = getPlayerAccount(player) 
        if not isGuestAccount(account) then 
            logOut(player) -- Log them out. 
        end 
    end 
    addEventHandler("onPlayerLogout",getRootElement(),loggedOut) 
end 
addEventHandler("onResourceStart", resourceRoot, logAllOut) 
  
function playerSpawn (spawnX, spawnY, spawnZ, team, permission, skin, weapons, player, skinName, sR, sG, sB, rot, dim, int) 
    local playerAccount = getPlayerAccount(player) 
    local hasPermission = false 
    if getAccountData(playerAccount, "override") then 
        hasPermission = true     
    else 
        if permission:lower() == "none" then 
            hasPermission = true 
        end 
        local outerPerm = split(permission, ";") or {permission} 
        for i,v in ipairs(outerPerm) do 
            local permArray = split(v, ",") 
            if #permArray == 2 then 
                local permType = permArray[1] 
                local permTo = permArray[2] 
                if permType:lower() == "group" then 
                    if exports.MGacl:isPlayerInGroup(player, permTo) then hasPermission = true end 
                    if isMayhemEnabled and free2[permTo] then hasPermission = true end 
                elseif permType:lower() == "gang" then 
                    local gang = getAccountData(playerAccount, "gang") 
                    if gang and gang:lower() == permTo:lower() then hasPermission = true end 
                end 
            end 
        end 
    end 
    if hasPermission then  
        local spawnTeam = getTeamFromName(team) 
        if not rot then rot = 0 end 
        spawnPlayer (player, spawnX , spawnY, spawnZ + 1, rot, skin, 0, 0, spawnTeam) 
        setElementDimension(player, dim or 0) 
        setElementInterior(player, int or 0) 
        fadeCamera (player, true) 
        setCameraInterior (player, int or 0 ) 
        setCameraTarget (player, player) 
        local tR , tG , tB = getTeamColor(spawnTeam) 
        local r = sR or tR 
        local g = sG or tG 
        local b = sB or tB 
        local blip = createBlipAttachedTo(player, 0, 2, r, g, b, 255, 0, 300, getRootElement()) 
        setElementVisibleTo(blip, player, false) 
        setPlayerNametagColor(player, r, g, b) 
        if(weapons) then 
            local weps = split(weapons, ",") 
            for i, node in ipairs(weps) do 
                --outputConsole(node) 
                local wepinfo = split(node, ".") 
                local wepid = wepinfo[1] 
                --outputConsole(wepid) 
                local wepammo = wepinfo[2] 
                --outputConsole(wepammo) 
                giveWeapon ( player, wepid, wepammo ) 
            end 
        end 
        setAccountData(playerAccount, "lastSpawnPerm", permission) 
        setElementData(player, "class", skinName) 
         
        if getResourceState(getResourceFromName("MGpolice")) == "running" then 
            showPlayerHudComponent(player, "crosshair", true) 
        end 
         
        if armorTeams[team] then 
            setPedArmor(player, 100) 
        end 
         
        triggerClientEvent(player, "onSpawnSuccessful", getRootElement()) 
    else 
        triggerClientEvent(player, "onSpawnError", getRootElement() , "You are not in this Gang/Squad/Company") 
    end 
end 
  
addEvent("onPlayerSpawnButton", true) 
addEventHandler("onPlayerSpawnButton", getRootElement(), playerSpawn) 
  
  
function playerDespawn() 
    local player = source 
    for i,v in ipairs(getAttachedElements(player)) do 
        if getElementType(v) == "blip" and getElementParent(getElementParent(v)) == resourceRoot then 
            destroyElement(v) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerDespawn) 
addEventHandler("onPlayerQuit", getRootElement(), playerDespawn) 
  
function saveProperty(a, b, c, playah) 
    local player = playah or source 
    local playeraccount = getPlayerAccount(player) 
    if not isPedDead(player) then 
        local x, y, z = getElementPosition(player) 
        local rot = getPedRotation(player) 
         
        setAccountData(playeraccount, "x", x) 
        setAccountData(playeraccount, "y", y) 
        setAccountData(playeraccount, "z", z) 
        setAccountData(playeraccount, "rot", rot) 
         
        local skin = getElementModel(player) 
        setAccountData(playeraccount, "skin", skin) 
         
        local team = getTeamName(getPlayerTeam(player)) 
        setAccountData(playeraccount, "team", team) 
         
        local weaponsarray = {} 
        for i=1, 12 do 
            if(getPedWeapon(player, i) ~= 0 and getPedTotalAmmo(player, i) > 0) then 
                table.insert(weaponsarray, getPedWeapon(player, i) .. "." .. getPedTotalAmmo(player, i)) 
            end 
        end 
         
        local weaponstring = table.concat(weaponsarray,",") 
        setAccountData(playeraccount, "weapons", weaponstring) 
        setAccountData(playeraccount, "aliveonquit", true) 
        setAccountData(playeraccount, "class", getElementData(player, "class")) 
         
        local r,g,b = getPlayerNametagColor(player) 
        setAccountData(playeraccount, "r", r) 
        setAccountData(playeraccount, "g", g) 
        setAccountData(playeraccount, "b", b) 
         
        local dimension = getElementDimension(player) 
        local interior = getElementInterior(player) 
        setAccountData(playeraccount, "interior", interior) 
        setAccountData(playeraccount, "dimension", dimension) 
    else 
        setAccountData(playeraccount, "aliveonquit", false) 
        setAccountData(playeraccount, "x", nil) 
        setAccountData(playeraccount, "y", nil) 
        setAccountData(playeraccount, "z", nil) 
        setAccountData(playeraccount, "permission", nil) 
        setAccountData(playeraccount, "team", nil) 
        setAccountData(playeraccount, "skin", nil) 
        setAccountData(playeraccount, "weapons", nil) 
        setAccountData(playeraccount, "class", nil) 
        setAccountData(playeraccount, "r", nil) 
        setAccountData(playeraccount, "g", nil) 
        setAccountData(playeraccount, "b", nil) 
        setAccountData(playeraccount, "rot", nil) 
        setAccountData(playeraccount, "dimension", nil) 
        setAccountData(playeraccount, "interior", nil) 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), saveProperty) 
  
function wasPlayerAlive() 
    if getAccountData(getPlayerAccount(source), "aliveonquit") then 
        --outputConsole("Seems like playah wus alive!") 
        local playerAccount = getPlayerAccount(source) 
        local x = getAccountData(playerAccount, "x") 
        local y = getAccountData(playerAccount, "y") 
        local z = getAccountData(playerAccount, "z") 
        local rot = getAccountData(playerAccount, "rot") 
        local team = getAccountData(playerAccount, "team") 
        local permission = getAccountData(playerAccount, "lastSpawnPerm") 
        local skin = getAccountData(playerAccount, "skin") 
        local weps = getAccountData(playerAccount, "weapons") 
        local skinName = getAccountData(playerAccount, "class") 
        local r = getAccountData(playerAccount, "r") 
        local g = getAccountData(playerAccount, "g") 
        local b = getAccountData(playerAccount, "b") 
        local dim = getAccountData(playerAccount, "dimension") 
        local int = getAccountData(playerAccount, "interior") 
         
        playerSpawn(x , y , z, team, permission, skin, weps, source, skinName, r, g, b, rot, dim, int) 
    else 
        showSpawnScreen(source) 
    end 
end 
  
addEvent("wasPlayerAliveEvent", true) 
addEventHandler("wasPlayerAliveEvent", getRootElement(), wasPlayerAlive) 
  
function loggedOut() 
    cancelEvent() 
    outputChatBox("You can't log out!", source, 255, 0 ,0) 
end 
  
function stopdown() 
    local players = getElementsByType("player") 
    for i, player in ipairs(players) do 
        saveProperty(nil, nil, nil, player) 
        killPed(player) 
        logOut(player) 
    end 
end 
addEventHandler("onResourceStop", resourceRoot, stopdown) 
  
function showSpawnScreen(player) 
    local account = getPlayerAccount(player) 
    local houses = exports.jhousing:getAccountHouses(account) 
    triggerClientEvent(player, "showSpawn", player, houses) 
end 
addEventHandler("onPlayerWasted", root, function() showSpawnScreen(source) end) 

Link to comment

try set this:

  
local tR , tG , tB = getTeamColor(spawnTeam) 
  
  

to this:

  
local tR , tG , tB = getTeamColor(getPlayerTeam(player)) 
  

change this:

  
        local r = sR or tR 
        local g = sG or tG 
        local b = sB or tB 
  

to:

  
        if(sR) then  
        local r = sR  
        else 
        local r = tR 
        end 
       if(sG) then   
        local g = sG  
      else  
        local g = tG 
       end 
       if(sB) then 
        local b = sB  
      else  
        local b = tB 
      end 
  

Link to comment

another errors:

[2014-12-23 17:54:09] WARNING: RGlogin\spawn_server.lua:73: Bad argument @ 'getTeamFromName' [Expected string at argument 1, got boolean]

[2014-12-23 17:54:09] WARNING: RGlogin\spawn_server.lua:81: Bad argument @ 'getTeamColor' [Expected team at argument 1, got boolean]

[2014-12-23 17:54:09] WARNING: RGlogin\spawn_server.lua:99: Bad argument @ 'setPlayerNametagColor' [Expected number at argument 2, got nil]

[2014-12-23 17:54:09] WARNING: RGlogin\spawn_server.lua:115: Bad argument @ 'getResourceState' [Expected resource-data at argument 1, got boolean]

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