KariiiM Posted August 17, 2015 Share Posted August 17, 2015 (edited) Hey guys, i face a small problem in same time a big one, i tried to make a resource for camera system,i want to release it to the community since there's no resource like that, Everything scripted fine,but i got a problem in unbinding a key, the key of returning with setCameraTarget. So, when the player press "accept" the function "bind" will be binded, untill now everything is fine , but when the Camera Points shows, after pressing the key "X", it doesn't be unbinded, so here's the problem. ~Regards. --Part of my code: (this problem is on Client side,server side is fine) addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then guiSetVisible(window,false) showCursor(false) unbindKey("X", "down", bind) elseif (source == accept) then local row,col = guiGridListGetSelectedItem(camGrid) if row and col and row ~= -1 and col ~= -1 then guiSetVisible(window,false) showCursor(true) outputChatBox ("Camera: Press X to stop the camera.",0,255,0) local x = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),3) local y = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),4) local z = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),5) local cx = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),6) local cy = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),7) local cz = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),8) triggerServerEvent("Camera:watch",localPlayer,guiGridListGetSelectedItem(camGrid)+1) bindKey("X", "down", bind) else outputChatBox ("Camera System: You didn't selecte the item.",0,180,23) end end end) function bind(key) if key == "X" then setCameraTarget(localPlayer) showChat(true) end end Edited August 17, 2015 by Guest Link to comment
Moderators Citizen Posted August 17, 2015 Moderators Share Posted August 17, 2015 Maybe you can try something cleaner like this: addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then exitCamera() elseif (source == accept) then local row,col = guiGridListGetSelectedItem(camGrid) if row and col and row ~= -1 and col ~= -1 then guiSetVisible(window,false) showCursor(true) outputChatBox ("Camera: Press X to stop the camera.",0,255,0) local x = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),3) local y = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),4) local z = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),5) local cx = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),6) local cy = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),7) local cz = guiGridListGetItemText (camGrid, guiGridListGetSelectedItem (camGrid),8) triggerServerEvent("Camera:watch",localPlayer,guiGridListGetSelectedItem(camGrid)+1) bindKey("X", "down", exitCamera) else outputChatBox ("Camera System: You didn't select the item.",0,180,23) end end end) function exitCamera() guiSetVisible(window, false) showCursor(false) unbindKey("X", "down", exitCamera) setCameraTarget(localPlayer) showChat(true) end Yyou were doing the unbindKey call only if the user clicked on the cancel button, but not when you pressed the "X" key See if it works like this. Link to comment
KariiiM Posted August 17, 2015 Author Share Posted August 17, 2015 Thanks Citizen, that's what i wanted to do exactly Link to comment
Moderators Citizen Posted August 17, 2015 Moderators Share Posted August 17, 2015 No problem Link to comment
KariiiM Posted August 17, 2015 Author Share Posted August 17, 2015 Why when i shoose a camera point far of my place or closed to me ,after i return the camera with "setCameraTarget" the ped fall under the ground,what's the solution to avoid this problem? Link to comment
Moderators Citizen Posted August 18, 2015 Moderators Share Posted August 18, 2015 Are you using the setElementPosition function for the player ? If so, make sure you do not set the Z position too low. If you are sure it's not the problem, then it might be a streaming issue (objects that are far from the camera are "streamed out" for better performance, so the buildings, ground etc, are kinda unloaded) just freeze the player for 1 or 2 seconds to let the game enough time to reload the unloaded objects and then unfreeze him. Link to comment
KariiiM Posted August 18, 2015 Author Share Posted August 18, 2015 No im not using this function, but i'll try the second idea i think it's usefull and fit my problem Edit: Worked great ,thanks for the ideas Citizen! Link to comment
Moderators Citizen Posted August 18, 2015 Moderators Share Posted August 18, 2015 Glad to hear that ! Have fun scripting 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