Jump to content

Heshan_Shalinda_eUnlock

Members
  • Posts

    49
  • Joined

  • Last visited

Details

  • Gang
    MTA
  • Location
    Sri Lanka
  • Occupation
    Scripter
  • Interests
    MTA Scripting

Recent Profile Visitors

59 profile views

Heshan_Shalinda_eUnlock's Achievements

Snitch

Snitch (10/54)

3

Reputation

  1. I got this but in this you are triggering a server event on client side but I want to trigger a client Event from server side as the reciprocal of this. I want to show window open/close state other players in the server. Tell me what are the failures in my script because when I use this it only shows yo me. -- Client Side -- local function open_event(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request() triggerServerEvent("onVehicleWindowOpenRequest", localPlayer, seatWindows[0]); end addCommandHandler("open", open_request) addEvent("open", true) addEventHandler( "open", localPlayer, open_event ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request, false ) -- Server Side -- addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); I don't understand what's wrong in this script could you please tell me what's wrong in this script. Thank you.................
  2. Exactly not ! I want to make vehicle function which change the vehicleWindowState open/close make visible to other players nearby/ in the server. Did you get that? This is my coding............... -- Client Side -- function callClientFunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do arg[key] = tonumber(value) or value end end loadstring("return "..funcname)()(unpack(arg)) end addEvent("onServerCallsClientFunction", true) addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction) GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[3] = guiCreateWindow(129, 311, 105, 121, "Open Shutters", false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.button[13] = guiCreateButton(9, 27, 41, 39, "Shutter 01", false, GUIEditor.window[3]) GUIEditor.button[14] = guiCreateButton(54, 71, 41, 39, "Shutter 04", false, GUIEditor.window[3]) GUIEditor.button[15] = guiCreateButton(54, 27, 41, 39, "Shutter 02", false, GUIEditor.window[3]) GUIEditor.button[16] = guiCreateButton(10, 71, 40, 39, "Shutter 03", false, GUIEditor.window[3]) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function open() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 4, not isVehicleWindowOpen( playerVehicle, 4 ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end end addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open ) function open2() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 2, not isVehicleWindowOpen( playerVehicle, 2 ) ) then outputChatBox( "Front Right Window switched" ) else outputChatBox( "You don't have window!" ) end end end end addEventHandler ( "onClientGUIClick", GUIEditor.button[15], open2 ) function open3() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 5, not isVehicleWindowOpen( playerVehicle, 5 ) ) then outputChatBox( "Back Left Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addEventHandler ( "onClientGUIClick", GUIEditor.button[16], open3 ) function open4() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 3, not isVehicleWindowOpen( playerVehicle, 3 ) ) then outputChatBox( "Back Right Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addEventHandler ( "onClientGUIClick", GUIEditor.button[14], open4 ) function guiackapa () if guiGetVisible ( GUIEditor.window[3] ) then guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) else guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end end addEvent( "ShowGUI", false ) addEventHandler ( "ShowGUI", getRootElement(), guiackapa ) bindKey("F10","down",guiackapa) end ) -- Server Script -- function callClientFunction(client, funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do if (type(value) == "number") then arg[key] = tostring(value) end end end -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {})) end addCommandHandler("callFunction", function (player, cmd, functionName) callClientFunction(player, functionName) end, false, false) I have tried many functions like triggerClientEvent in server side script part but I was not able do make my script successfully. This is my script which I have used triggerClientEvent and TriggerServerEvent, Could you please help me on this. I want to make windowState visible to other players in the server when I switch window using gui Button.. This part is with triggering I don't understand how to get rid of this mess... please help me... -- Client Side -- GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[3] = guiCreateWindow(129, 311, 105, 121, "Open Shutters", false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.button[13] = guiCreateButton(9, 27, 41, 39, "Shutter 01", false, GUIEditor.window[3]) GUIEditor.button[14] = guiCreateButton(54, 71, 41, 39, "Shutter 04", false, GUIEditor.window[3]) GUIEditor.button[15] = guiCreateButton(54, 27, 41, 39, "Shutter 02", false, GUIEditor.window[3]) GUIEditor.button[16] = guiCreateButton(10, 71, 40, 39, "Shutter 03", false, GUIEditor.window[3]) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function open_event(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end function open_request() triggerServerEvent("onVehicleWindowOpenRequest", root, seatWindows[0]); end addCommandHandler("open", open_request) addEvent("open", true) addEventHandler( "open", localPlayer, open_event ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request, false ) function open_event2(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Front Right Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request2() triggerServerEvent("onVehicleWindowOpenRequest2", root, seatWindows[1]); end addCommandHandler("open2", open_request2) addEvent("open2", true) addEventHandler( "open2", localPlayer, open_event2 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[15], open_request2, false ) function open_event3(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Rear Left Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request3() triggerServerEvent("onVehicleWindowOpenRequest3", root, seatWindows[2]); end addCommandHandler("open3", open_request3) addEvent("open3", true) addEventHandler( "open3", localPlayer, open_event3 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[16], open_request3, false ) function open_event4(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Rear Right Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request4() triggerServerEvent("onVehicleWindowOpenRequest4", root, seatWindows[3]); end addCommandHandler("open4", open_request4) addEvent("open4", true) addEventHandler( "open4", localPlayer, open_event4 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[14], open_request4, false ) function guiackapa () if guiGetVisible ( GUIEditor.window[3] ) then guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) else guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end end addEvent( "ShowGUI", false ) addEventHandler ( "ShowGUI", getRootElement(), guiackapa ) bindKey("F10","down",guiackapa) end ) -- Server Side -- addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); addEvent("onVehicleWindowOpenRequest2", true); addEventHandler("onVehicleWindowOpenRequest2", root, function(wndid) triggerClientEvent("open2", client, wndid); end ); addEvent("onVehicleWindowOpenRequest3", true); addEventHandler("onVehicleWindowOpenRequest3", root, function(wndid) triggerClientEvent("open3", client, wndid); end ); addEvent("onVehicleWindowOpenRequest4", true); addEventHandler("onVehicleWindowOpenRequest4", root, function(wndid) triggerClientEvent("open4", client, wndid); end ); Thank you....
  3. Can I bind this into gui button and make some client side function occur by clicking that gui button?? Thank you for your help
  4. I have used this script and create a resource but the doorstate does not working but when we are not in a vehicle the message will we displayed. How to fix this?
  5. Thank you for your help but I want to know why we use callClientFunction. And I want to know if I can use it to an only client side function make visible to all the players in the server.
  6. I want to know the usage of CallClientFunction to make my further scripts. Could someone please help me on this?
  7. Don't worry I have found out how to do it without any help thank you...
  8. Other Players in the server can not see the windows open/close state when I do that and I also can't see that when they do that. What is the reason for that?
  9. I have fixed it as you said but there isn't anything happened. It was same as before. Is there anything wrong in my code local function open_event(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request() triggerServerEvent("onVehicleWindowOpenRequest", localPlayer, seatWindows[0]); end addCommandHandler("open", open_request) addEvent("open", true) addEventHandler( "open", localPlayer, open_event ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request, false ) Trigger Server Event before triggerServerEvent("onVehicleWindowOpenRequest", root, seatWindows[0]); Trigger Server Event now triggerServerEvent("onVehicleWindowOpenRequest", localPlayer, seatWindows[0]); Is there anything wrong
  10. I have a problem in Changing Vehicle Window State. When I switch window of the car using GUI button it will only be visible to me not to other players in the server. And When another player in the server switch car window using his GUI button it will only be visible to him. Someone please tell me why is that ? My code is this -- Client Side Part -- GUIEditor.button[13] = guiCreateButton(0.73, 0.11, 0.12, 0.22, "Shutter 01", true, GUIEditor.window[1]) GUIEditor.button[14] = guiCreateButton(0.86, 0.36, 0.12, 0.22, "Shutter 04", true, GUIEditor.window[1]) GUIEditor.button[15] = guiCreateButton(0.86, 0.11, 0.11, 0.22, "Shutter 02", true, GUIEditor.window[1]) GUIEditor.button[16] = guiCreateButton(0.73, 0.36, 0.12, 0.22, "Shutter 03", true, GUIEditor.window[1]) local function open_event(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request() triggerServerEvent("onVehicleWindowOpenRequest", root, seatWindows[0]); end addCommandHandler("open", open_request) addEvent("open", true) addEventHandler( "open", localPlayer, open_event ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request, false ) local function open_event2(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Front Right Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request2() triggerServerEvent("onVehicleWindowOpenRequest2", root, seatWindows[1]); end addCommandHandler("open2", open_request2) addEvent("open2", true) addEventHandler( "open2", localPlayer, open_event2 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[15], open_request2, false ) local function open_event3(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Rear Left Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request3() triggerServerEvent("onVehicleWindowOpenRequest3", root, seatWindows[2]); end addCommandHandler("open3", open_request3) addEvent("open3", true) addEventHandler( "open3", localPlayer, open_event3 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[16], open_request3, false ) local function open_event4(wndid) local playerVehicle = getPedOccupiedVehicle ( source ) if ( playerVehicle ) then if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then outputChatBox( "Rear Right Window Switched" ) else outputChatBox( "You don't have window!" ) end end end local function open_request4() triggerServerEvent("onVehicleWindowOpenRequest4", root, seatWindows[3]); end addCommandHandler("open4", open_request4) addEvent("open4", true) addEventHandler( "open4", localPlayer, open_event4 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[14], open_request4, false ) -- Server Side Part -- addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); addEvent("onVehicleWindowOpenRequest2", true); addEventHandler("onVehicleWindowOpenRequest2", root, function(wndid) triggerClientEvent("open2", client, wndid); end ); addEvent("onVehicleWindowOpenRequest3", true); addEventHandler("onVehicleWindowOpenRequest3", root, function(wndid) triggerClientEvent("open3", client, wndid); end ); addEvent("onVehicleWindowOpenRequest4", true); addEventHandler("onVehicleWindowOpenRequest4", root, function(wndid) triggerClientEvent("open4", client, wndid); end ); How to solve this problem I'm tired of thinking this problem please help me to fix this... And Thank you very much for your help...
  11. I have created a script to change the player seat on clientGUIClick and I have created a window and add buttons, etc.... It works 90% good, But my problem is, when I enter a vehicle and click the seat I'm now sitting on in the GUI Button my current seat will change to some other seat. And If there will be a player on the seat I will change after clicking the GUI that player will be switched to my previous seat. I need some help fixing this. -- Client Side Part -- GUIEditor.button[9] = guiCreateButton(0.02, 0.11, 0.12, 0.22, "Seat 01", true, GUIEditor.window[1]) GUIEditor.button[10] = guiCreateButton(0.02, 0.36, 0.12, 0.22, "Seat 03", true, GUIEditor.window[1]) GUIEditor.button[11] = guiCreateButton(0.15, 0.11, 0.12, 0.22, "Seat 02", true, GUIEditor.window[1]) GUIEditor.button[12] = guiCreateButton(0.15, 0.36, 0.12, 0.22, "Seat 04", true, GUIEditor.window[1]) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01, false) -- Server Side Part -- function findFreeVehicleSlot(vehicle) local seat_count = 1 + getVehicleMaxPassengers( vehicle ) for slot_off=1,seat_count do local sitting_ped = getVehicleOccupant( vehicle, slot_off - 1 ) if (sitting_ped == false) then -- is no ped sitting on that slot? return slot_off - 1 -- return the free slot index end end -- There is no free slot so return false. return false end function changeSeat01 ( ) thePed = client theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then local sitting_ped = getVehicleOccupant( theVehicle, 0 ) warpPedIntoVehicle ( thePed, theVehicle, 0 ) if (sitting_ped) then local free_slot = findFreeVehicleSlot( theVehicle ) if (free_slot) then warpPedIntoVehicle( sitting_ped, theVehicle, free_slot ) end end end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) I think I have added all the details I must add to solve my problem. Need help to fix this problem. Thank you very much for helping me using your valuable time.
  12. I also have the same question and no one is answering it.......
  13. Thank you very much at last someone have seen this I have posted 3 topics relating this thank you very much
  14. Is it possible? Can I use my vehicle shutter open/ close resource to be visible to all players when a player click on his gui?? Thanks for your help.
  15. I want to make a client Side function visible to others in the server. Is it possible ?
×
×
  • Create New...