Bean666 Posted June 23, 2016 Share Posted June 23, 2016 The functions nothing say to me. Seriously I tried It's really important for me oh please, if you tried then show us your code. Link to comment
mores Posted June 23, 2016 Author Share Posted June 23, 2016 You see Shaman123 somebody want to help like Tails. You know Shaman123 I have nothing against you but why you did not want help me? I think it's simple for you. Link to comment
Bean666 Posted June 23, 2016 Share Posted June 23, 2016 i helped you before. and im just telling you to learn, you cant just ask for anything you need. you also need to try something yourself. i already gave you the functions. just go to wiki and learn what the function does. why can't you try something and show us what you did? for that timer DX thing you'll just need 3 things to learn setTimer dxDrawText onClientRender i'm not against you or anything. but again, you can't just ask for anything you need. i actually like to do scripts for you it's fun but you have to try / do it yourself. Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 This should be enought for it local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 function drawCounterSHI() dxDrawText("Your vehicle will change in: "..counter,0,sY*0.8,sX,sY,tocolor(r,g,b,255),2,"default","center","top",false,false,false) end addEventHandler("onClientRender",root,drawCounterSHI) setTimer(function() counter = counter - 1 if counter < 0 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) Its not tested but it should works. NOTE: ITS CLIENT SIDE Regards. Link to comment
mores Posted June 23, 2016 Author Share Posted June 23, 2016 Overkillz thank you but it dont works. I paste it unter main scrip (which TAILS wrote for me) nothing happen and it will be start on every map on 3.2.1..go ? Link to comment
Bean666 Posted June 23, 2016 Share Posted June 23, 2016 tails script is serverside, paste overkillz code into client side. make a new file called client.lua or whatever and paste this on your meta.xml Link to comment
mores Posted June 23, 2016 Author Share Posted June 23, 2016 thank you shaman And was only last one problem The script both should starting in every map afer 3.2.1...go ) Link to comment
Overkillz Posted June 23, 2016 Share Posted June 23, 2016 Do a triggerClientEvent using the following function addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then --Do your trigger to the source to prevent any other bug .. end end) Link to comment
mores Posted June 24, 2016 Author Share Posted June 24, 2016 Need I use triggerServerEvent too ? Link to comment
ozulus Posted June 24, 2016 Share Posted June 24, 2016 It's that easy.. function startVehicleChanging() if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() end end) Link to comment
Tails Posted June 24, 2016 Share Posted June 24, 2016 Nice. I didn't know you could just add events from other resources like that. Link to comment
mores Posted June 24, 2016 Author Share Posted June 24, 2016 ozulus can you make the same with counter ? Link to comment
Bean666 Posted June 24, 2016 Share Posted June 24, 2016 no it's because the Counter script is client side. you could use triggerServerEvent, i managed to do it. Link to comment
Overkillz Posted June 24, 2016 Share Posted June 24, 2016 It's boring seeing people that doesn't try to do anything by himself. There is something called wiki where you can see everything with some examples ... Next time avoid requesting script without knowing whats the meaning of server side or client side ... function startVehicleChanging() if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end end) local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 function drawCounterSHI() dxDrawText("Your vehicle will change in: "..counter,0,sY*0.8,sX,sY,tocolor(r,g,b,255),2,"default","center","top",false,false,false) end function startEverything() addEventHandler("onClientRender",root,drawCounterSHI) setTimer(function() counter = counter - 1 if counter < 0 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) Link to comment
mores Posted June 25, 2016 Author Share Posted June 25, 2016 (edited) wow Thanks ! but counter don't die when map is finish and it should start after counting down on every map like main script Edited June 25, 2016 by Guest Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 replace the timer in client with this , not tested: function startEverything() addEventHandler("onClientRender",root,drawCounterSHI) timer = setTimer(function() counter = counter - 1 if counter < 0 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) add this to client: addEvent("removeCounter", true) addEventHandler("removeCounter", getRootElement(), function () removeEventHandler("onClientRender", root, draw) if isTimer(timer) then killTimer(timer) end end ) replace the onRaceStateChanging event with this. not tested! addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end if (new =="LoadingMap") then triggerClientEvent(source,"removeCounter",source) if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end end end ) if that's not what you want here are the states: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping Link to comment
mores Posted June 25, 2016 Author Share Posted June 25, 2016 Doesn't work or i've done something wrong Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 show me your server side and clientside? anyways here are the states: you could change LoadingMap with these, LoadingMap maybe wont be the one you'll need: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping Link to comment
mores Posted June 25, 2016 Author Share Posted June 25, 2016 SERVERSIDE vehicleIDS = { 602, 545, 496, 517, 401, 410, 518, 600, 527, 436, 589, 580, 419, 439, 533, 549, 526, 491, 474, 445, 467, 604, 426, 507, 547, 585, 405, 587, 409, 466, 550, 492, 566, 546, 540, 551, 421, 516, 529, 592, 553, 577, 488, 511, 497, 548, 563, 512, 476, 593, 447, 425, 519, 520, 460, 417, 469, 487, 513, 581, 510, 509, 522, 481, 461, 462, 448, 521, 468, 463, 586, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 523, 470, 598, 499, 588, 609, 403, 498, 514, 524, 423, 532, 414, 578, 443, 486, 515, 406, 531, 573, 456, 455, 459, 543, 422, 583, 482, 478, 605, 554, 530, 418, 572, 582, 413, 440, 536, 575, 534, 567, 535, 576, 412, 402, 542, 603, 475, 449, 537, 538, 570, 441, 464, 501, 465, 564, 568, 557, 424, 471, 504, 495, 457, 539, 483, 508, 571, 500, 444, 556, 429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 606, 607, 610, 590, 569, 611, 584, 608, 435, 450, 591, 594 } function startVehicleChanging() if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end end) CLIENTSIDE local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 function drawCounterSHI() dxDrawText("Your vehicle will change in: "..counter,0,sY*0.8,sX,sY,tocolor(r,g,b,255),2,"default","center","top",false,false,false) end function startEverything() if isTimer(counter) then killTimer(counter) end addEventHandler("onClientRender",root,drawCounterSHI) setTimer(function() counter = counter - 1 if counter < 1 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) addEvent("removeCounter", true) addEventHandler("removeCounter", getRootElement(), function () removeEventHandler("onClientRender", root, draw) if isTimer(timer) then killTimer(timer) end end ) addEvent("loading map, NoMap, undefined, PreGridCountdown, GridCountdown, Running, MidMapVote, SomeoneWon, TimesUp, EveryoneFinished, PostFinish, NextMapSelect, NextMapVote, ResourceStopping ",true) addEventHandler("loading map, NoMap, undefined, PreGridCountdown, GridCountdown, Running, MidMapVote, SomeoneWon, TimesUp, EveryoneFinished, PostFinish, NextMapSelect, NextMapVote, ResourceStopping ",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end if (new =="LoadingMap") then triggerClientEvent(source,"removeCounter",source) if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end end end ) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) Link to comment
Bean666 Posted June 25, 2016 Share Posted June 25, 2016 lol..... what are u even doing Server: function startVehicleChanging() if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end if (new =="LoadingMap") then triggerClientEvent(source,"removeCounter",source) if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end end end ) Client.lua function startEverything() addEventHandler("onClientRender",root,drawCounterSHI) timer = setTimer(function() counter = counter - 1 if counter < 0 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) addEvent("removeCounter", true) addEventHandler("removeCounter", getRootElement(), function () removeEventHandler("onClientRender", root, draw) if isTimer(timer) then killTimer(timer) end end ) Link to comment
mores Posted June 26, 2016 Author Share Posted June 26, 2016 shaman the counter should be restart not stop Link to comment
Bean666 Posted June 26, 2016 Share Posted June 26, 2016 try. replace server with this. function startVehicleChanging() vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end if (new =="LoadingMap") then triggerClientEvent(source,"removeCounter",source) if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end end end ) Link to comment
mores Posted June 26, 2016 Author Share Posted June 26, 2016 when i've done it main script dont work and cunter too Link to comment
Bean666 Posted June 26, 2016 Share Posted June 26, 2016 i get what you mean now , try just using resetTimer you could do it by yourself now. Link to comment
mores Posted June 26, 2016 Author Share Posted June 26, 2016 Paste it on client ? resetTimer(counter) Link to comment
Recommended Posts