Jump to content

[HELP] 50p Spawn Script


Recommended Posts

In this script link given: https://community.multitheftauto.com/index.php?p= ... ls&id=1152 all of the groups are free and i can make it passworded witch will work but im getting resources step by step and I need this permission, like some other 50+ server goes like You need permission to join this group. How do I do that? There are too many files i cant post so please help me make it ACL permission

Link to comment

Try this:

-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 

Also, make a new ACL group for each team (eg. team "Police") you want to restrict and add for each player inside that group:

<group name="Police" > 
    <object name="user.USERNAME" />  
</group> 

Not tested but should work.

Link to comment
Try this:
-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 

Also, make a new ACL group for each team you want to restrict and add for each player inside that group:

<group name="Police" > 
    <object name="user.USERNAME" />  
</group> 

Not tested but should work.

What file name?

Link to comment
Try this:
-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 

In this one where do I put this lua? what file name?

Link to comment
  
g_root = getRootElement( ); 
classGroups = { }; 
  
  
addEvent( "spawn_clientRequestSpawn", true ); 
addEventHandler( "spawn_clientRequestSpawn", g_root, 
    function( categoryIndex, classIndex, skinIndex, password ) 
        if skinIndex then 
            local class = classGroups[ categoryIndex ].classes[ classIndex ]; 
            if class.password then 
                if not password or password == "" then 
                    triggerClientEvent( client, "spawn_requestPassword", root, class.name ); 
                    return; 
                elseif password ~= class.password then 
                    outputChatBox( "The password you typed in is incorrect! Try again or cancel to choose different class.", client, 200, 50, 50 ); 
                    triggerClientEvent( client, "spawn_requestPassword", root, class.name ); 
                    return; 
                end 
            end 
-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 
            local skin = class.skinMngr.skins[ skinIndex ]; 
            local spawn = true; 
            local spawned; 
            --[[if not classGroups[ cetegoryIndex ].owner then -- if there is NO owner of the clan/gang spawn player 
                spawn = true; 
            else -- if there IS owner of the clan/gang then check if he's member of the clan/gang 
                 
            end]] 
             
            if spawn then 
                if not class.team then 
                    class.team = createTeam( class.name, class.color.red, class.color.green, class.color.blue ); 
                end 
                 
                local plrTeam = getPlayerTeam( client ); 
                if ( ( plrTeam ) and ( plrTeam ~= class.team ) and ( countPlayersInTeam( plrTeam ) == 1 ) ) then 
                    destroyElement( plrTeam ); 
                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 ) 
                setElementData( client, "skin", skin.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 
                    destroyElement( class.team ); 
                    class.team = nil; 
                end 
            end 
        end 
    end 
); 
  
addEvent( "spawn_receivePassword", true ); 
addEventHandler( "spawn_receivePassword", g_root, 
    function( ) 
     
    end 
); 
  
  
addEventHandler( "onPlayerSpawn", g_root, 
    function ( ) 
     
    end 
); 
  
addEventHandler( "onPlayerWasted", g_root, 
    function( ) 
        fadeCamera( source, false, 4 ); 
        setTimer( requestMenu, 5000, 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 
) 

Like this?

Link to comment

While Im adding the script in this script

-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 

I will have to ONLY change the | To the one I want acl permission?

( class.name ) 

and...

isObjectInACLGroup( "user." 

Only user part correct?

Link to comment

class.name is read from the spawn_locations.map file. That's the group name you need to add to acl.xml. Why don't you read my previous posts?

...

Also, make a new ACL group for each team (eg. team "Police") you want to restrict and add for each player inside that group:

<group name="Police" > 
    <object name="user.USERNAME" />  
</group> 

Not tested but should work.

This was just an example. If you don't have class with name "Police" don't add that group to acl.xml. Just add the groups that you want to restrict. If you haven't modified spawn_locations.map then you can try "Las Venturas Police" instead.

Link to comment
  • 2 weeks later...
While Im adding the script in this script
-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 

I will have to ONLY change the | To the one I want acl permission?

( class.name ) 

and...

isObjectInACLGroup( "user." 

Only user part correct?

In this post here... I'm trying to say where it shows class.name is that where i put the name of the team I want ACL connect?

EDIT: Here is my s_main.lua

  
g_root = getRootElement( ); 
classGroups = { }; 
  
  
addEvent( "spawn_clientRequestSpawn", true ); 
addEventHandler( "spawn_clientRequestSpawn", g_root, 
    function( categoryIndex, classIndex, skinIndex, password ) 
        if skinIndex then 
            local class = classGroups[ categoryIndex ].classes[ classIndex ]; 
            if class.password then 
                if not password or password == "" then 
                    triggerClientEvent( client, "spawn_requestPassword", root, class.name ); 
                    return; 
                elseif password ~= class.password then 
                    outputChatBox( "The password you typed in is incorrect! Try again or cancel to choose different class.", client, 200, 50, 50 ); 
                    triggerClientEvent( client, "spawn_requestPassword", root, class.name ); 
                    return; 
                end 
            end 
-- make new line (21) in s_main.lua 
            local classACL = aclGetGroup( Police ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL and ( not isGuestAccount( plrAccount ) ) or ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) ) then 
                outputChatBox( "You are not member of this team/gang. Please, choose different team!", client, 200, 50, 50 ); 
                requestMenu( client ); 
                return; 
            end 
            local skin = class.skinMngr.skins[ skinIndex ]; 
            local spawn = true; 
            local spawned; 
            --[[if not classGroups[ cetegoryIndex ].owner then -- if there is NO owner of the clan/gang spawn player 
                spawn = true; 
            else -- if there IS owner of the clan/gang then check if he's member of the clan/gang 
                
            end]] 
            
            if spawn then 
                if not class.team then 
                    class.team = createTeam( class.name, class.color.red, class.color.green, class.color.blue ); 
                end 
                
                local plrTeam = getPlayerTeam( client ); 
                if ( ( plrTeam ) and ( plrTeam ~= class.team ) and ( countPlayersInTeam( plrTeam ) == 1 ) ) then 
                    destroyElement( plrTeam ); 
                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 ) 
                setElementData( client, "skin", skin.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 
                    destroyElement( class.team ); 
                    class.team = nil; 
                end 
            end 
        end 
    end 
); 
  
addEvent( "spawn_receivePassword", true ); 
addEventHandler( "spawn_receivePassword", g_root, 
    function( ) 
    
    end 
); 
  
  
addEventHandler( "onPlayerSpawn", g_root, 
    function ( ) 
    
    end 
); 
  
addEventHandler( "onPlayerWasted", g_root, 
    function( ) 
        fadeCamera( source, false, 4 ); 
        setTimer( requestMenu, 5000, 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 
) 

Now when I try joining Police team it says "You are not member of this team/gang. Please, choose different team!" and I am in the Police ACL team... also when I try joining different teams it still says "You are not member of this team/gang. Please, choose different team!" even if its not ACL...

Link to comment

Simply copy and replace the old code at line 21:

-- line 21: 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL ) then 
                if ( not isGuestAccount( plrAccount ) ) and ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) then 
                    outputChatBox( "You are not member of this team/gang. Choose different team!", client, 200, 50, 50 ); 
                    requestMenu( client ); 
                    return; 
                elseif isGuestAccount( plrAccount ) then 
                    outputChatBox( "If you are member of \"" .. class.name .. "\" then please log in before you proceed.", client, 200, 50, 50 ); 
                    requestMenu( client ); 
                    return; 
                end 
            end 

Tested it and it works.

Link to comment
Simply copy and replace the old code at line 21:
-- line 21: 
            local classACL = aclGetGroup( class.name ); 
            local plrAccount = getPlayerAccount( client ); 
            if ( classACL ) then 
                if ( not isGuestAccount( plrAccount ) ) and ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) then 
                    outputChatBox( "You are not member of this team/gang. Choose different team!", client, 200, 50, 50 ); 
                    requestMenu( client ); 
                    return; 
                elseif isGuestAccount( plrAccount ) then 
                    outputChatBox( "If you are member of \"" .. class.name .. "\" then please log in before you proceed.", client, 200, 50, 50 ); 
                    requestMenu( client ); 
                    return; 
                end 
            end 

Tested it and it works.

Wait... on line 2 do i have to change class.name?

EDIT: Guess not I changed it back to class.name and works :P Thank you

Link to comment
  • 2 months later...

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