isa_Khamdan Posted August 15, 2013 Share Posted August 15, 2013 Hello , I made this function triggered to the server side , The function Restarts the resource named with player name so if your name is Player it will restart the resource name Player if it exists but I tested it and it's not working so can anyone tell me how to fix this problem? addEvent("Restart",true) addEventHandler("Restart",root, function() local account = getPlayerAccount(source) -- get account element from player element local accname = getAccountName(account) -- get account name from account element local RestartResource = getResourceFromName ( "accname" ) if isObjectInACLGroup("user."..accname,aclGetGroup("PCS")) then if ( RestartResource and theResource == RestartResource ) then restartResource(RestartResource) end end end ) The trigger in the client side addEventHandler("onClientGUIClick", root, function(Restart) if source == PCSbutton5 then triggerServerEvent("Restart",root,thePlayer) end end Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 You gave a string as resourcename, not your variable accName. :3 getResourceFromName( accName ) Link to comment
isa_Khamdan Posted August 15, 2013 Author Share Posted August 15, 2013 You gave a string as resourcename, not your variable accName. :3 getResourceFromName( accName ) It doesn't work? Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 I'm not on my phone right now, hang on. Checking your script edit; you didn't define the source but you did give 'thePlayer' as a variable in your client. try this; server; addEvent("Restart",true) addEventHandler("Restart",root, function( thePlayer ) local account = getPlayerAccount ( thePlayer ); local accname = getAccountName ( account ); local RestartResource = getResourceFromName ( tostring( accname ) ); if ( isObjectInACLGroup( "user." .. accname , aclGetGroup ( "PCS" ) ) then if ( RestartResource and theResource == RestartResource ) then restartResource(RestartResource) end end end ); client; addEventHandler("onClientGUIClick", root, function(Restart) if ( source == PCSbutton5 ) then triggerServerEvent("Restart",root, localPlayer); end end ); Link to comment
isa_Khamdan Posted August 15, 2013 Author Share Posted August 15, 2013 I'm not on my phone right now, hang on. Checking your scriptedit; you didn't define the source but you did give 'thePlayer' as a variable in your client. try this; server; addEvent("Restart",true) addEventHandler("Restart",root, function( thePlayer ) local account = getPlayerAccount ( thePlayer ); local accname = getAccountName ( account ); local RestartResource = getResourceFromName ( tostring( accname ) ); if ( isObjectInACLGroup( "user." .. accname , aclGetGroup ( "PCS" ) ) then if ( RestartResource and theResource == RestartResource ) then restartResource(RestartResource) end end end ); client; addEventHandler("onClientGUIClick", root, function(Restart) if ( source == PCSbutton5 ) then triggerServerEvent("Restart",root, localPlayer); end end ); Error in line 7 ) expected near then Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 My bad; addEvent( "Restart" , true ); addEventHandler( "Restart" , root, function( thePlayer ) local account = getPlayerAccount ( thePlayer ); local accname = getAccountName ( account ); local RestartResource = getResourceFromName ( tostring( accname ) ); if ( isObjectInACLGroup( "user." .. accname , aclGetGroup ( "PCS" ) ) ) then if ( RestartResource ) then restartResource( RestartResource ) end end end ); oh and btw, you didn't define this variable before; theResource Did you define it somewhere else cause I removed it right now. Link to comment
isa_Khamdan Posted August 15, 2013 Author Share Posted August 15, 2013 My bad; addEvent( "Restart" , true ); addEventHandler( "Restart" , root, function( thePlayer ) local account = getPlayerAccount ( thePlayer ); local accname = getAccountName ( account ); local RestartResource = getResourceFromName ( tostring( accname ) ); if ( isObjectInACLGroup( "user." .. accname , aclGetGroup ( "PCS" ) ) ) then if ( RestartResource ) then restartResource( RestartResource ) end end end ); oh and btw, you didn't define this variable before; theResource Did you define it somewhere else cause I removed it right now. hmm I think it's not defined because when I click on the restart button it doesn't do anythings ( no errors ) and in console this message appear " voiceptt: This server does not have voice enabled " Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 Well I can tell you for what it's getting used. The onResourceStart eventHandler returns a variable called theResource. So they can say if a type of resource is restarted. why are you even adding 1 eventHandler for all the buttons? If I may ask. You can simply do this; addEventHandler ( "onClientGUIClick", gui["_gameInterface_quitlbl"], btnRestart, false ); function btnRestart() -- todo end Give me your client-side script. :3 Link to comment
isa_Khamdan Posted August 15, 2013 Author Share Posted August 15, 2013 Well I can tell you for what it's getting used. The onResourceStart eventHandler returns a variable called theResource. So they can say if a type of resource is restarted.why are you even adding 1 eventHandler for all the buttons? If I may ask. You can simply do this; addEventHandler ( "onClientGUIClick", gui["_gameInterface_quitlbl"], btnRestart, false ); function btnRestart() -- todo end Give me your client-side script. :3 the button name is PCSbutton5 addEventHandler("onClientGUIClick", root, function(Restart) if ( source == PCSbutton5 ) then triggerServerEvent("Restart",root, localPlayer); end end ); addEventHandler("onClientGUIClick", root, function(Arrow) if ( source == PCScheckbox2 ) then if not (isPedInVehicle ( localPlayer ) ) then guiCheckBoxSetSelected(PCScheckbox2,false) end if guiCheckBoxGetSelected(PCScheckbox2) then triggerServerEvent("Arrow",localPlayer) else triggerServerEvent("Arrow",localPlayer) end end end ) addEventHandler("onClientGUIClick", root, function() if source == PCSbutton2 then guiSetVisible(windowPCS, false) showCursor(false) end end ) addEventHandler("onClientGUIClick", root, function(Spawn) if source == PCSbutton3 then triggerServerEvent("Spawn",localPlayer) end end ) addEventHandler("onClientGUIClick", root, function(Warp) if source == PCSbutton4 then triggerServerEvent("Warp",localPlayer) end end ) Link to comment
tosfera Posted August 15, 2013 Share Posted August 15, 2013 Where's the gui? I need that too haha. I'll be testing some things on my local server haha 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