Jump to content

Search the Community

Showing results for tags 'triggerserverevent'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 9 results

  1. I'm very noob at scripting :' (, but i did this: (It's a script for the Imponte Deluxo of GTA Online) Serverside: function deluxe ( player ) local vehicle = getPedOccupiedVehicle(player) if isElement(vehicle) then if getVehicleDoorOpenRatio(vehicle,5) > 0 then setVehicleDoorOpenRatio(vehicle,5,0,ms) setVehicleDoorOpenRatio(vehicle,4,0,ms) setVehicleDoorOpenRatio(vehicle,0,0,ms) else setVehicleDoorOpenRatio(vehicle,5,1,ms) setVehicleDoorOpenRatio(vehicle,4,1,ms) setVehicleDoorOpenRatio(vehicle,0,1,ms) end end end addEvent( "deluxo", true ) addEventHandler( "deluxo", resourceRoot, deluxe) This function puts the Deluxo on flying mode, works fine if i use addCommandHandler instead addEventHandler... Clientside: triggerServerEvent ( "deluxo", resourceRoot) this is the triggerServerEvent that is activated by BindKey (Shift) but i got at line2 on serverside: Bad Argument @ ´getPedoccupiedvehicle´ [Expected Ped at Argument 1, got nil] I need help
  2. Hey guys please help!!! I have been researching and researching for almost 8 hours now. And I am just stuck as to what I am fundamentally getting wrong here. Main goal: I would like when the person gets into a vehicle, read the license plates, send plates to the server, read a table in the DB, then send info from table back to the client to use in other functions. What works: I am OK server side, I am able to read from the database and pass that back to the client, but can only trigger server side with a RegisterCommand. Issue: Client side, when I start using triggers inside of an if statement it stops working, (yes I am sure conditions are met). I am currently only able to trigger the server function with a register command, when I try to send a trigger from the client to the server, it will not launch the server function. Working code: client.Lua RegisterNetEvent("servertest:output_status") --from server.Lua AddEventHandler("servertest:output_status", function(argument) TriggerEvent("chatMessage", "[Success]", {0,255,0}, argument) TriggerEvent("servertest:vehStatus", argument) end) Citizen.CreateThread(function() while true do Citizen.Wait(1000) local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, false) then AddEventHandler("servertest:vehStatus", function(vehstatus) TriggerEvent("chatMessage", "[LOOP]", {0,255,0}, vehstatus) end) end end end) server.Lua: RegisterCommand("get", function(source, args) --I dont want to trigger this way, I want to trigger from client side MySQL.Async.fetchAll('SELECT * FROM vehicle_data WHERE plate = @plate', { ['@plate'] = "TSTPLATE1" }, function(result) if result[1] then local vehstatus = result[1].status TriggerClientEvent("servertest:output_status", source, vehstatus) cb(true) else cb(false) end end) end) What I want to do: client.Lua: RegisterNetEvent("servertest:output_status") --from server.Lua AddEventHandler("servertest:output_status", function(argument) TriggerEvent("chatMessage", "[Success]", {0,255,0}, argument) --never receive message TriggerEvent("servertest:vehStatus", argument) --not used now, save for later use end) Citizen.CreateThread(function() while true do Citizen.Wait(1000) local playerPed = GetPlayerPed(-1) if IsPedInAnyVehicle(playerPed, false) then local playerVeh = GetVehiclePedIsIn(playerPed, false) local vehPlates = GetVehicleNumberPlateText(playerVeh) TriggerServerEvent("servertest:sendInfo", vehPlates) --this trigger never happens even though criteria is met end end end) server.Lua: RegisterNetEvent("servertest:sendInfo") AddEventHandler("servertest:sendInfo", function(plates) MySQL.Async.fetchAll('SELECT * FROM vehicle_data WHERE plate = @plate', { ['@plate'] = plates }, function(result) if result[1] then local vehstatus = result[1].status TriggerClientEvent("servertest:output_status", source, vehstatus) cb(true) else cb(false) end end) end) I guess maybe what I need to know is just how to trigger something server side from the client side without using a RegisterCommand. I don't know how to structure it in my code, do I need to do it outside the while loop? I've tried but haven't been successful.
  3. Hello, I want to pass the Client-player with the function triggerServerEvent (for example to trigger an event and ONLY the client triggered the event so that ONLY HE would receive a message) and this is how i would do it: triggerServerEvent("blabla", localPlayer, bla) But MTA-wiki says the following sentence: Warning: You should use the global variable client serverside instead of passing the localPlayer by parameter or source. Otherwise event faking (passing another player instead of the localPlayer) would be possible. So I assume, that I shouldn't do it the way I just posted above, but I have no clue what they mean by this sentence and how else I should do it then.. Could anyone explain this WITH an example?
  4. It's because of the onClientResourceStart event, but i dont know why its triggering it twice. Thanks function create() triggerServerEvent ( "create_s", resourceRoot) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), create) and the server function create_s() outputChatBox("lol") end addEvent("create_s", true) addEventHandler("create_s", resourceRoot, create_s)
  5. Is it possible to prevent trggerServerEvent and TriggerClientEvent from triggering other resources? Thanks
  6. Hi, I will doing job, but I always have got problem with arguments in trigger I read Elements Tree on wiki, but I still do not know what this is about When player hit marker then s-side must create vehicle. C-side StartJobM = createMarker (-165.35049, 1059.69141, 18.74219, 'cylinder', 1.0, 22, 38, 199, 255) function StartJob (hitPlayer, matchingDimension) if isPedInVehicle (hitPlayer) then outputChatBox ("You can't hit marker when u are in vehicle!") cancelEvent () if getElementType(hitPlayer) == getlocalPlayer then triggerServerEvent ("poj", localPlayer ) outputChatBox ("Created vehicle!") end end end addEventHandler ("onClientMarkerHit", StartJobM, StartJob) StartJobM = createMarker (-165.35049, 1059.69141, 18.74219, 'cylinder', 1.0, 22, 38, 199, 255) function StartJob (hitPlayer, matchingDimension) if isPedInVehicle (hitPlayer) then outputChatBox ("You can't hit marker when u are in vehicle!") cancelEvent () if getElementType(hitPlayer) == getlocalPlayer then triggerServerEvent ("poj", localPlayer ) outputChatBox ("Created vehicle!") end end end addEventHandler ("onClientMarkerHit", StartJobM, StartJob) S-side: function VehicleC() lcvehi = createVehicle (422, -158.49141, 1051.20691, 19.75892) end addEvent("poj") addEventHandler("poj", getRootElement(), VehicleC) Please, explain me how i Can triggering
  7. Everythink is just working fine. The problem is that the triggerServerEvent is not triggering to the server. line: 43, 69, 75, 81, 87 CLIENT.LUA function create_weapon(veh) local x,y,z = getElementPosition(veh) local obj = createObject ( 357, x,y,z) attachElements ( obj, veh, 0,0,0,0,0,0 ) setElementData(localPlayer,"obj",obj) local gun1 = createWeapon(30, x,y,z) local gun2 = createWeapon(30, x,y,z) local gun3 = createWeapon(30, x,y,z) local gun4 = createWeapon(30, x,y,z) setElementData(localPlayer,"gun1",gun1) setElementData(localPlayer,"gun2",gun2) setElementData(localPlayer,"gun3",gun3) setElementData(localPlayer,"gun4",gun4) attachElements ( gun1, obj, 1.18, 0.24, 0, 0, -5, 0) attachElements ( gun2, obj, 1.18, -0.55, 0, 0, -5, 0) attachElements ( gun3, obj, 1.18, -0.55, 0.35, 0, -5, 0) attachElements ( gun4, obj, 1.18, 0.24, 0.35, 0, -5, 0) setWeaponState(gun1, "ready") setWeaponState(gun2, "ready") setWeaponState(gun3, "ready") setWeaponState(gun4, "ready") addEventHandler ( "onClientPreRender", root, rotate_object ) end function rotate_object() local veh = getPedOccupiedVehicle ( localPlayer ) local obj = getElementData(localPlayer,"obj") local _,_,rz = getVehicleComponentRotation(veh, "misc_a") local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") triggerServerEvent("rotateWeapon", localPlayer, veh,obj,rx,rz) end fired1 = false fired2 = true fired3 = true fired4 = true function fire() if getKeyState( "mouse1" ) == true then local veh = getPedOccupiedVehicle(localPlayer) if isPedInVehicle(localPlayer) and getElementModel(veh) == 602 then if fired1 == false then local gun1 = getElementData (localPlayer, "gun1") fired1 = true fired2 = false triggerServerEvent ( "fire_server1", localPlayer,veh,gun1) elseif fired2 == false then local gun2 = getElementData (localPlayer, "gun2") fired2 = true fired3 = false triggerServerEvent ( "fire_server2", localPlayer,veh,gun2) elseif fired3 == false then local gun3 = getElementData (localPlayer, "gun3") fired3 = true fired4 = false triggerServerEvent ( "fire_server3", localPlayer,veh,gun3) elseif fired4 == false then local gun4 = getElementData (localPlayer, "gun4") fired4 = true fired1 = false triggerServerEvent ( "fire_server4", localPlayer,veh,gun4) end setTimer ( fire, 200, 1 ) end end end bindKey("mouse1", "down", fire) function fire_client(veh,gun1) outputChatBox("fire_client1",2,1,10) outputChatBox ( "gun1",255,0,100 ) fireWeapon(gun1) fireWeapon(gun1) local x,y,z = getElementPosition(veh) local sound_gun1 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun1, 500 ) setSoundVolume(sound_gun1, 1) end addEvent("fire_client", true) addEventHandler("fire_client", root, fire_client) function fire_client2(veh,gun2) outputChatBox("fire_client2",2,1,10) outputChatBox ( "gun2",255,0,100 ) fireWeapon(gun2) fireWeapon(gun2) local x,y,z = getElementPosition(veh) local sound_gun2 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun2, 500 ) setSoundVolume(sound_gun2, 1) end addEvent("fire_client2", true) addEventHandler("fire_client2", root, fire_client2) function fire_client3(veh,gun3) outputChatBox("fire_client3",2,1,10) outputChatBox ( "gun3",255,0,100 ) fireWeapon(gun3) fireWeapon(gun3) local x,y,z = getElementPosition(veh) local sound_gun3 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun3, 500 ) setSoundVolume(sound_gun3, 1) end addEvent("fire_client3", true) addEventHandler("fire_client3", root, fire_client3) function fire_client4(veh,gun4) outputChatBox("fire_client4",2,1,10) outputChatBox ( "gun4",255,0,100 ) fireWeapon(gun4) fireWeapon(gun4) local x,y,z = getElementPosition(veh) local sound_gun4 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun4, 500 ) setSoundVolume(sound_gun4, 1) end addEvent("fire_client4", true) addEventHandler("fire_client4", root, fire_client4) SERVER.LUA function rotateWeapon(veh,obj,rx,rz) rx = (-rx) setElementAttachedOffsets ( obj, 0, 0, 0, 0, rx+7, rz+96) end addEvent("rotateWeapon", true) addEventHandler("rotateWeapon", root, rotateWeapon) function fire_server1(veh,gun1) outputChatBox("fire_server1") triggerClientEvent("fire_client1", getRootElement(), veh,gun1) end addEvent("fire_server1", true) addEventHandler("fire_server1",getRootElement(), fire_server1) function fire_server2(veh,gun1) outputChatBox("fire_server2") triggerClientEvent("fire_client2", getRootElement(), veh,gun2) end addEvent("fire_server2", true) addEventHandler("fire_server2",getRootElement(), fire_server2) function fire_server3(veh,gun1) outputChatBox("fire_server3") triggerClientEvent("fire_client3", getRootElement(), veh,gun3) end addEvent("fire_server3", true) addEventHandler("fire_server3",getRootElement(), fire_server3) function fire_server4(veh,gun1) outputChatBox("fire_server4") triggerClientEvent("fire_client4", getRootElement(), veh,gun4) end addEvent("fire_server4", true) addEventHandler("fire_server4",getRootElement(), fire_server4)
  8. I can't find an error in this script, what's wrong here? The message says that the event is not added serverside... coreh_client.lua local tableToSendVip = { [1] = guiGetText( hc_edith['edith_ec_X'] ), [4] = guiGetText( hc_edith['edith_etc_X'] ), [2] = guiGetText( hc_edith['edith_ec_Y'] ), [5] = guiGetText( hc_edith['edith_etc_Y'] ), [3] = guiGetText( hc_edith['edith_ec_Z'] ), [6] = guiGetText( hc_edith['edith_etc_Z'] ), [7] = guiGetText( hc_edith['edith_exc_X'] ), [10] = guiGetText( hc_edith['edith_extc_X'] ), [8] = guiGetText( hc_edith['edith_exc_Y'] ), [11] = guiGetText( hc_edith['edith_extc_Y'] ), [9] = guiGetText( hc_edith['edith_exc_Z'] ), [12] = guiGetText( hc_edith['edith_extc_Z'] ), [13] = guiGetText( hc_guih['edith_intID'] ), [14] = guiGetText( hc_guih['edith_dim'] ), [15] = guiGetText( hc_guih['edith_cost'] ) }; for i, v in ipairs( tableToSendVip ) do tableToSendVip[ i ] = tonumber( tableToSendVip[ i ] ); end; triggerServerEvent( 'onPlayerAttemptCreateHouseVip', me, tableToSendVip ); triggerEvent( 'HPV_SetVisible', me, false ); end, false ); coreh_server.lua addEvent( 'onPlayerAttemptcreateHouseVip', true ); addEventHandler( 'onPlayerAttemptcreateHouseVip', root, function( rt ) createHouseVip( true, #sqly.Query( "SELECT * FROM house_data" ) + 1, '', '', unpack( rt ) ); outputChatBox( 'A casa VIP foi criada com sucesso!', client, 255, 255, 0 ); end ); Any ideas?
  9. السلام عليكم ورحمة الله وبركاته ابي مساعدة بسيطة وهي انا مسوي ترايجر وكلمة في ملف سيرفر ( عدد ) وارسلت هاذي الكلمة بالترايجر لملف الكلينت لكنها ما توصل - التجربة -- Server -- function Miner () MyGold = "10" triggerClientEvent(source, "getMinerHave", source, MyGold ) end addEventHandler("onResourceStart", resourceRoot, Miner) -- Client -- addEvent("getMinerHave", true) addEventHandler ("getMinerHave", root, function ( MyGold ) MyGold = tonumber(MyGold) end ) addEventHandler("onClientRender", root, function() dxDrawText(MyJewels, 270, (screenH - 80), ((screenW - 100) / 2) + 100, ( (screenH - 80)) + 60, tocolor(255, 255, 255, theMinerImage), 1.00, "default-bold", "left", "center", false, false, false, false, false) end ) وبس هذا كل شي ابي اعرف ليش الكلمة ما تروح لملف الكلينت
×
×
  • Create New...