damien111 Posted August 3, 2012 Share Posted August 3, 2012 Restricting ALC Groups and Classes together is what i want. For invite only groups. But i cant figure it out. Heres my server side code which is all i edited. 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; --[[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 skin.modelId == 29 and not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(client)), aclGetGroup ( "SoS" ) ) then spawn = false 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 ) 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 ); 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 ) and the line i added is after line 18. its if skin.modelId == 29 and not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(client)), aclGetGroup ( "SoS" ) ) then spawn = false end Im new to scripting but i know other langauges. Thanks in advance! Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 Topic moved to "Scripting" section. Maybe if you would tell us what is the exact problem. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 Thanks for replying so quicky! Its just not restricting it. i thought that would do it. but it didnt. Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 Are you sure that: "skin.modelId" value is "29"? Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 hahaha, Im almost positive. lemme check, ima be so stupid feeling if it isnt. Edit: Nope, its id 29, for the white drug dealer. https://wiki.multitheftauto.com/wiki/Skins_Page_1 the last one on that is my skin. Im stumped. Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 Ok, let's try debugging and see what it outputs: 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; --[[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]] outputChatBox ( "model id: ".. skin.modelId ) outputChatBox ( "in acl: ".. tostring ( isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(client)), aclGetGroup ( "SoS" ) ) ) ) if skin.modelId == 29 and not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(client)), aclGetGroup ( "SoS" ) ) then spawn = false 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 ) 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 ); 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 ) Use that and post here what it outputs to chat box. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 How to debug? is it like /debug script ZIPARCHIVENAME? or what Link to comment
triplesnake Posted August 3, 2012 Share Posted August 3, 2012 How to debug? is it like /debug script ZIPARCHIVENAME? or what /debugscript 3 Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 I did the command now what Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 By debugging I meant adding outputs to see what it returns, do what I said in my latest post. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 nvm figured it out, this came up : SPAWNTEST\c_main.lua:28:addEventHandler:'onClientRender' with this function is already handled Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 That has nothing to do with your problem, do what I said above. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 i did, i spawned as the class, SoT, and it came up with that error i did /debugscript 3, spawned, and it had that error. ill try again Link to comment
Castillo Posted August 3, 2012 Share Posted August 3, 2012 Did you replace your code with the one I posted above? if so, then it has to output some data. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 Let me try again. i mightive clicked the wrong one they have sam name, one just has a 1 after it. Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 ERROR:SPAWNTEST2/S_main.lua:19: attempt to concatenate a boolean value is what it gave me Link to comment
damien111 Posted August 3, 2012 Author Share Posted August 3, 2012 AHA! I FIGURED IT OUT I added the acl/group in the in game manager, but not in acl.xml. Sorry for this. i hope you will forgive me for being so dumb. Link to comment
Castillo Posted August 4, 2012 Share Posted August 4, 2012 Oh, so I assume it's working now. Link to comment
damien111 Posted August 4, 2012 Author Share Posted August 4, 2012 No it isnt. Sorry. I meant to post this yesterday. I have no debug errors but it is not locking the dam class. :C I will keep working but feel free to help(PLEASE) Link to comment
Castillo Posted August 4, 2012 Share Posted August 4, 2012 Mind uploading the whole spawn system to: mediafire.com and paste the link here? so I can see what's wrong. Link to comment
damien111 Posted August 4, 2012 Author Share Posted August 4, 2012 its just not restricting it but, ok. i didnt make it im trying to edit some stuff. Here is the basic thing im trying to do: http://www.mediafire.com/?rgzy53f0rdgt3tt i didnt make this but im gonna make it better, but i need to know hw to restrict it to teams/groups/acl's anything like that. i just need to restric them. Link to comment
Castillo Posted August 4, 2012 Share Posted August 4, 2012 I found your problem, the value of: skin.modelId is a string, not a number, so the result is "29", not 29. if ( skin.modelId == "29" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SoS" ) ) ) then spawn = false end With that it'll work, tested. Link to comment
myonlake Posted August 4, 2012 Share Posted August 4, 2012 (edited) Also, just saying. Models are integers. When you try to compare a string with an integer, it will return an error. Then again when you try to output a message, which tells you your location, you don't need to separately mark them as floats/integers in general, because the message will always return a string, so adding tostring() or tonumber() won't affect anything. What you have there is the first thing I told you, which is trying to compare a string with an integer. So as solidsnake already advised you to do, is to add the string (quotation marks). It's logical and interesting afterall. Good luck! Edited August 5, 2012 by Guest Link to comment
damien111 Posted August 5, 2012 Author Share Posted August 5, 2012 I added all that i needed. it worked with 1 but when i added more it didnt here is my code. 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; --[[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 ( skin.modelId == "165" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SPECIALUNITS" ) ) ) then spawn = false if ( skin.modelId == "286" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SPECIALUNITS" ) ) ) then spawn = false if ( skin.modelId == "285" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SWAT" ) ) ) then spawn = false if ( skin.modelId == "287" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "MF" ) ) ) then spawn = false if ( skin.modelId == "312" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "MF" ) ) ) then spawn = false if ( skin.modelId == "294" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SPECIALFORCES" ) ) ) then spawn = false if ( skin.modelId == "153" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "STAFF" ) ) ) then spawn = false if ( skin.modelId == "211" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "STAFF" ) ) ) then spawn = false if ( skin.modelId == "30" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "CLO" ) ) ) then spawn = false if ( skin.modelId == "122" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "NINJA" ) ) ) then spawn = false if ( skin.modelId == "29" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SoA" ) ) ) then spawn = false if ( skin.modelId == "115" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "SoA" ) ) ) then spawn = false if ( skin.modelId == "165" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "MIB" ) ) ) then spawn = false if ( skin.modelId == "164" and not isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( client ) ), aclGetGroup ( "MIB" ) ) ) then spawn = false 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 ) 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 ); 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 ) Also , how can i make it so it detects when someone cant spawn as the class and then displays a message box. or panel or something. ps- Thanks myonlake! 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