Deep thinker Posted December 2, 2016 Share Posted December 2, 2016 hi ,i have scripted a gate depending on account name , but i have started it ,it creates the marker and the object but the object isn't moving door = createObject ( 3089, 2004.5 , -1280 , 36.900001525879 , 0, 0, 0 ) marker = createMarker ( 2005.5 , -1280 , 35.900001525879 , 'cylinder', 1, 0, 0, 0, 255 ) -- after creating function openForProMax() local thePlayer = getAccountPlayer ( promax ) -- get the client attached to the account if ( getElementType ( thePlayer ) == "player" ) then moveObject ( door,2000, 2004.5 , -1280 , 30.900001525879, 0, 0, 0 ) else return end end addEventHandler ( 'onMarkerHit', marker, openForProMax ) function closeAfterProMax() moveObject ( door,2000, 2004.5 , -1280 , 36.900001525879, 0, 0, 0 ) end addEventHandler ( 'onMarkerLeave', marker, closeAfterProMax ) Link to comment
ViRuZGamiing Posted December 3, 2016 Share Posted December 3, 2016 1 hour ago, ProMax said: local thePlayer = getAccountPlayer ( promax ) promax isn't a defined variable also you're trying to get the account not the name. I think you're looking for this; door = createObject (3089, 2004.5 , -1280 , 36.9 , 0, 0, 0) marker = createMarker ( 2005.5 , -1280 , 35.9 , 'cylinder', 1, 0, 0, 0, 255) -- after creating function moveGate(hitElement, time, targetX, targetY, targetZ, moveRX, moveRY, moveRZ) if (getElementType(hitElement) == "player") then if (getPlayerName(hitElement) == "promax" then moveObject ( door, time, targetX, targetY , targetZ, moveRX, moveRY, moveRZ) else return end else return end end addEventHandler ( 'onMarkerHit', marker, function(hitElement) moveGate(hitElement, 2000, 2004.5 , -1280 , 30.9, 0, 0, 0) end) addEventHandler ( 'onMarkerLeave', marker, function(hitElement) moveGate(hitElement ,2000, 2004.5 , -1280 , 36.9, 0, 0, 0) end) I changed the use of 2 function which do the same and made them use parameters, first you check if the hitelement is a player then you check if the name is equal to the string. i've also cleaned up the long coordinates btw xxx.9000000000xx doesn't matter, just make it xxx.9 (Not tested, just written) Kind regards Link to comment
Deep thinker Posted December 3, 2016 Author Share Posted December 3, 2016 it's not working + it didn't create anything . also what is the point of this 23 minutes ago, ViRuZGamiing said: moveObject ( door, time, targetX, targetY , targetZ, moveRX, moveRY, moveRZ) also i want it to be depending on account name not the player's name Link to comment
ViRuZGamiing Posted December 3, 2016 Share Posted December 3, 2016 Then you'll need to use getAccountName(hitElement) instead What does the debug/console say? Link to comment
Dimos7 Posted December 3, 2016 Share Posted December 3, 2016 (edited) door = createObject ( 3089, 2004.5 , -1280 , 36.900001525879 , 0, 0, 0 ) marker = createMarker ( 2005.5 , -1280 , 35.900001525879 , 'cylinder', 1, 0, 0, 0, 255 ) -- after creating function openForProMax(thePlayer) local account = getPlayerAccount(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then if account == "promax" then moveObject ( door,2000, 2004.5 , -1280 , 30.900001525879, 0, 0, 0 ) else return end end end addEventHandler ( 'onMarkerHit', marker, openForProMax ) function closeAfterProMax() moveObject ( door,2000, 2004.5 , -1280 , 36.900001525879, 0, 0, 0 ) end addEventHandler ( 'onMarkerLeave', marker, closeAfterProMax ) Edited December 3, 2016 by Dimos7 Link to comment
ViRuZGamiing Posted December 3, 2016 Share Posted December 3, 2016 38 minutes ago, Dimos7 said: door = createObject ( 3089, 2004.5 , -1280 , 36.900001525879 , 0, 0, 0 ) marker = createMarker ( 2005.5 , -1280 , 35.900001525879 , 'cylinder', 1, 0, 0, 0, 255 ) -- after creating function openForProMax(thePlayer) local account = getPlayerAccount(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then if account == "promax" then moveObject ( door,2000, 2004.5 , -1280 , 30.900001525879, 0, 0, 0 ) else return end end end addEventHandler ( 'onMarkerHit', marker, openForProMax ) function closeAfterProMax() moveObject ( door,2000, 2004.5 , -1280 , 36.900001525879, 0, 0, 0 ) end addEventHandler ( 'onMarkerLeave', marker, closeAfterProMax ) That won't work, I can see an error without trying "attempting to compare player data with string" getPlayerAccount Returns the player's account object, or false if the player passed to the function is invalid. Link to comment
Dimos7 Posted December 3, 2016 Share Posted December 3, 2016 door = createObject ( 3089, 2004.5 , -1280 , 36.900001525879 , 0, 0, 0 ) marker = createMarker ( 2005.5 , -1280 , 35.900001525879 , 'cylinder', 1, 0, 0, 0, 255 ) -- after creating function openForProMax(thePlayer) local account = getPlayerAccount(thePlayer) if ( getElementType ( thePlayer ) == "player" ) then if getAccountName(account) == "promax" then moveObject ( door,2000, 2004.5 , -1280 , 30.900001525879, 0, 0, 0 ) else return end end end addEventHandler ( 'onMarkerHit', marker, openForProMax ) function closeAfterProMax() moveObject ( door,2000, 2004.5 , -1280 , 36.900001525879, 0, 0, 0 ) end addEventHandler ( 'onMarkerLeave', marker, closeAfterProMax ) yes i forget that sorry fast type mistake Link to comment
ViRuZGamiing Posted December 3, 2016 Share Posted December 3, 2016 So I tested my code (changed to work with account name now) and it does work, but I hope it's ment to be a door in the air. Else check your coordinates. Spoiler door = createObject (3089, 2004.5 , -1280 , 36.9 , 0, 0, 0) marker = createMarker (2005.5, -1280, 35.9, 'cylinder', 1, 0, 0, 0, 255) -- after creating function moveGate(hitElement, time, targetX, targetY, targetZ, moveRX, moveRY, moveRZ) if (getElementType(hitElement) == "player") then local thePlayer = getPlayerAccount(hitElement) if (thePlayer and getAccountName(thePlayer) == "NAMEHERE") then moveObject ( door, time, targetX, targetY , targetZ, moveRX, moveRY, moveRZ) end end end addEventHandler ( 'onMarkerHit', marker, function(hitElement) moveGate(hitElement, 2000, 2004.5 , -1280 , 30.9, 0, 0, 0) end) addEventHandler ( 'onMarkerLeave', marker, function(hitElement) moveGate(hitElement ,2000, 2004.5 , -1280 , 36.9, 0, 0, 0) end) Link to comment
Deep thinker Posted December 3, 2016 Author Share Posted December 3, 2016 actually the last code works,i would like to thank you for your efforts but i need to know something else ,i want to make the freeroam panel only for admin ACL,if you can it would be great Link to comment
LoPollo Posted December 3, 2016 Share Posted December 3, 2016 If i'm right the panel is accessible by F1 press and by typing "/fr" In fr_client.lua@Line1620 there's the function that shows (and hide) the panel. Insert the needed checks here. Another solution would be adding an handler on both keypress and on the chat event (i don't remember the name... onPlayerChat maybe) with a very high priority, cancelling the event. But i'm not sure if the event will still be triggered if the other handlers do not check if the event was cancelled Link to comment
Deep thinker Posted December 4, 2016 Author Share Posted December 4, 2016 On ٣/١٢/٢٠١٦ at 9:16 PM, LoPollo said: If i'm right the panel is accessible by F1 press and by typing "/fr" In fr_client.lua@Line1620 there's the function that shows (and hide) the panel. Insert the needed checks here. Another solution would be adding an handler on both keypress and on the chat event (i don't remember the name... onPlayerChat maybe) with a very high priority, cancelling the event. But i'm not sure if the event will still be triggered if the other handlers do not check if the event was cancelled function toggleFRWindow() if isPlayerInACL(thePlayer, "Admin") then if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end end addCommandHandler('fr', toggleFRWindow) failed :3 Link to comment
Captain Cody Posted December 4, 2016 Share Posted December 4, 2016 thePlayer Is not defined, isPlayerInACL Could be defined, but I'm not to sure https://wiki.multitheftauto.com/wiki/IsPlayerInACL function toggleFRWindow(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectinACL("user."..accName, "Admin") then if isWindowOpen(wndMain) then showCursor(false) hideAllWindows() colorPicker.closeSelect() else showCursor(true) showAllWindows() end end end addCommandHandler('fr', toggleFRWindow) Link to comment
ViRuZGamiing Posted December 4, 2016 Share Posted December 4, 2016 isPlayerInACL Needs the function as well function isPlayerInACL ( player, acl ) local account = getPlayerAccount ( player ) if ( isGuestAccount ( account ) ) then return false end return isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) end which is server sided and the code you have is, I guess, client sided so you need a trigger. On 3-12-2016 at 8:16 PM, LoPollo said: fr_client.lua@Line1620 @CodyL I suppose client sided because of the file name Link to comment
Captain Cody Posted December 4, 2016 Share Posted December 4, 2016 Did not notice that, Open = false function toggleFRWindow(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectinACL("user."..accName, "Admin") then if Open then Open = false showCursor(thePlayer,false) triggerClientEvent ( thePlayer, "OpenOrClose", thePlayer,false) colorPicker.closeSelect() else Open = true showCursor(thePlayer,true) triggerClientEvent ( thePlayer, "OpenOrClose", thePlayer,true) end end end addCommandHandler('fr', toggleFRWindow) Client - function OpenOrCloseClient(Open) if Open then showAllWindows() else hideAllWindows() colorPicker.closeSelect() end end addEvent( "OpenOrClose", true ) addEventHandler( "OpenOrClose", localPlayer, OpenOrCloseClient ) Not tested, was just a quick thing I made. Link to comment
AJXB Posted December 5, 2016 Share Posted December 5, 2016 (edited) 13 hours ago, CodyL said: Did not notice that, Open = false function toggleFRWindow(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectinACL("user."..accName, "Admin") then if Open then Open = false showCursor(thePlayer,false) triggerClientEvent ( thePlayer, "OpenOrClose", thePlayer,false) colorPicker.closeSelect() else Open = true showCursor(thePlayer,true) triggerClientEvent ( thePlayer, "OpenOrClose", thePlayer,true) end end end addCommandHandler('fr', toggleFRWindow) Client - function OpenOrCloseClient(Open) if Open then showAllWindows() else hideAllWindows() colorPicker.closeSelect() end end addEvent( "OpenOrClose", true ) addEventHandler( "OpenOrClose", localPlayer, OpenOrCloseClient ) Not tested, was just a quick thing I made. Mother of indentation.. press "Tab" once a while. http://pastebin.com/Y9ri2wxi Edited December 5, 2016 by gSub typo 2 Link to comment
Captain Cody Posted December 5, 2016 Share Posted December 5, 2016 I wrote it quickly before I had to leave, I didn't really pay attention to indentation. 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