Jump to content

Spawn error


PhantomDamn

Recommended Posts

Hola ... Queria saber que debo hacer con este script que me esta haciendo reiniciar mi spawn ( 50p )

aqui les dejo el script y el error

WARNING: [gameplay]/Gaby/s_main.lua:105: Bad argument @ 'countPlayersInTeam'

y aqui esta el s_main:

  
g_root = getRootElement( ); 
classGroups = { }; 
  
  
addEvent( "spawn_clientRequestSpawn", true ); 
addEventHandler( "spawn_clientRequestSpawn", g_root, 
    function( categoryIndex, classIndex, skinIndex ) 
        if skinIndex then 
            local class = classGroups[ categoryIndex ].classes[ classIndex ]; 
            local skin = class.skinMngr.skins[ skinIndex ]; 
            local spawn = true; 
            local spawned; 
            local restricted = false 
            if ( class.gang and tostring ( class.gang ) ~= "" ) then 
                restricted = true 
                spawn = ( getElementData ( client, "gang" ) == class.gang )  
            end 
             
            if spawn then 
                if not class.team then 
                    class.team = createTeam( class.name, class.color.red, class.color.green, class.color.blue ); 
                                        setTeamFriendlyFire ( class.team, false ) 
                end 
                spawned = spawnPlayer( 
                    client, 
                    skin.spawnLoc.x, 
                    skin.spawnLoc.y, 
                    skin.spawnLoc.z, 
                    skin.spawnLoc.rot, 
                    skin.modelId, 
                    0, 0, 
                    class.team 
                ); 
            end 
             
            if spawned then 
                setElementData( client, "team", class.name ) 
                fadeCamera( client, true ); 
                setCameraTarget( client, client ); 
                setTimer( setCameraTarget, 200, 1, client, client ); 
                 
                triggerClientEvent( client, "spawn_SpawnedSuccessfully", client ); 
                 
                --setPlayerMoney( client, 500 ); 
                for _, weapon in ipairs( class.weaponMngr.weapons ) do 
                    giveWeapon( client, weapon.id, weapon.ammo, false ); 
                end 
                createBlipAttachedTo( client, 0, 2, class.color.red, class.color.green, class.color.blue ) 
            else 
                triggerClientEvent( client, "spawn_FailedToSpawn", client ); 
                if countPlayersInTeam( class.team ) == 0 then 
                end 
            end 
        end 
    end 
); 
  
addEventHandler( "onPlayerSpawn", g_root, 
    function ( ) 
     
    end 
); 
  
addEventHandler( "onPlayerWasted", g_root, 
    function( ) 
        fadeCamera( source, false, 4 ); 
        setTimer( requestMenu, 1000, 1, source ); 
        deleteAllPlayerBlips( source ) 
    end 
); 
  
function requestMenu( player ) 
    callClientFunc( player, "showSpawnMenu", true, true ); 
    callClientFunc( player, "classSelected" ); 
end 
  
  
addCommandHandler( "kill", 
    function( plr ) 
        killPed( plr ); 
    end 
) 
  
  
  
function preloadClassesInfo( ) 
    local groups = getElementsByType( "category" ); 
    for _, group in ipairs( groups ) do 
        table.insert( classGroups, Group:New( group ) ); 
    end 
end 
addEventHandler( "onResourceStart", getResourceRootElement(), preloadClassesInfo ) 
  
  
function deleteAllPlayerBlips(player) 
    local elements = getAttachedElements(player) 
    if (elements) then 
        for i, element in ipairs(elements) do 
            if (getElementType(element) == "blip") then 
                destroyElement(element) 
            end 
        end 
    end 
    print( "number of players in team: " .. tostring( countPlayersInTeam( getPlayerTeam( player ) ) ) ); 
end 
  
addEventHandler( "onPlayerQuit", g_root, function() deleteAllPlayerBlips(source) end ); 
  
  
------------------------------------------------------------------------------------------ 
------------------------------------------------------------------------------------------ 
function callClientFunc( player, funcName, ... ) 
    if #{ ... } ~= 0 then 
        triggerClientEvent( player, "_clientCallFunction", root, funcName, ... ) 
    else 
        triggerClientEvent( player, "_clientCallFunction", root, funcName ) 
    end 
end 
  
addEvent( "_serverCallFunction", true ) 
addEventHandler( "_serverCallFunction", root,  
    function( funcName, ... ) 
        _G[ funcName ](...) 
    end 
) 

de ante mano les agradezco

Link to comment
  • MTA Team

Simplemente borra esa porcion de codigo ya que usualemente es bastante inutil..Te quedaria asi:

  
  
g_root = getRootElement( ); 
classGroups = { }; 
  
  
addEvent( "spawn_clientRequestSpawn", true ); 
addEventHandler( "spawn_clientRequestSpawn", g_root, 
    function( categoryIndex, classIndex, skinIndex ) 
        if skinIndex then 
            local class = classGroups[ categoryIndex ].classes[ classIndex ]; 
            local skin = class.skinMngr.skins[ skinIndex ]; 
            local spawn = true; 
            local spawned; 
            local restricted = false 
            if ( class.gang and tostring ( class.gang ) ~= "" ) then 
                restricted = true 
                spawn = ( getElementData ( client, "gang" ) == class.gang )  
            end 
            
            if spawn then 
                if not class.team then 
                    class.team = createTeam( class.name, class.color.red, class.color.green, class.color.blue ); 
                                        setTeamFriendlyFire ( class.team, false ) 
                end 
                spawned = spawnPlayer( 
                    client, 
                    skin.spawnLoc.x, 
                    skin.spawnLoc.y, 
                    skin.spawnLoc.z, 
                    skin.spawnLoc.rot, 
                    skin.modelId, 
                    0, 0, 
                    class.team 
                ); 
            end 
            
            if spawned then 
                setElementData( client, "team", class.name ) 
                fadeCamera( client, true ); 
                setCameraTarget( client, client ); 
                setTimer( setCameraTarget, 200, 1, client, client ); 
                
                triggerClientEvent( client, "spawn_SpawnedSuccessfully", client ); 
                
                --setPlayerMoney( client, 500 ); 
                for _, weapon in ipairs( class.weaponMngr.weapons ) do 
                    giveWeapon( client, weapon.id, weapon.ammo, false ); 
                end 
                createBlipAttachedTo( client, 0, 2, class.color.red, class.color.green, class.color.blue ) 
            else 
                triggerClientEvent( client, "spawn_FailedToSpawn", client ); 
                if countPlayersInTeam( class.team ) == 0 then 
                end 
            end 
        end 
    end 
); 
  
addEventHandler( "onPlayerSpawn", g_root, 
    function ( ) 
    
    end 
); 
  
addEventHandler( "onPlayerWasted", g_root, 
    function( ) 
        fadeCamera( source, false, 4 ); 
        setTimer( requestMenu, 1000, 1, source ); 
        deleteAllPlayerBlips( source ) 
    end 
); 
  
function requestMenu( player ) 
    callClientFunc( player, "showSpawnMenu", true, true ); 
    callClientFunc( player, "classSelected" ); 
end 
  
  
addCommandHandler( "kill", 
    function( plr ) 
        killPed( plr ); 
    end 
) 
  
  
  
function preloadClassesInfo( ) 
    local groups = getElementsByType( "category" ); 
    for _, group in ipairs( groups ) do 
        table.insert( classGroups, Group:New( group ) ); 
    end 
end 
addEventHandler( "onResourceStart", getResourceRootElement(), preloadClassesInfo ) 
  
  
function deleteAllPlayerBlips(player) 
    local elements = getAttachedElements(player) 
    if (elements) then 
        for i, element in ipairs(elements) do 
            if (getElementType(element) == "blip") then 
                destroyElement(element) 
            end 
        end 
    end 
end 
  
addEventHandler( "onPlayerQuit", g_root, function() deleteAllPlayerBlips(source) end ); 
  
  
------------------------------------------------------------------------------------------ 
------------------------------------------------------------------------------------------ 
function callClientFunc( player, funcName, ... ) 
    if #{ ... } ~= 0 then 
        triggerClientEvent( player, "_clientCallFunction", root, funcName, ... ) 
    else 
        triggerClientEvent( player, "_clientCallFunction", root, funcName ) 
    end 
end 
  
addEvent( "_serverCallFunction", true ) 
addEventHandler( "_serverCallFunction", root, 
    function( funcName, ... ) 
        _G[ funcName ](...) 
    end 
) 
  

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...