mores2 Posted August 13, 2016 Share Posted August 13, 2016 Who can tell me what is wrong with this script and what gui function should I use to repair it ? Link to comment
mores2 Posted August 13, 2016 Share Posted August 13, 2016 (edited) Client : local osW, osH = 1024,768 local csW, csH = guiGetScreenSize() local DrawText = dxDrawText function dxDrawText(...) arg[2], arg[3], arg[4], arg[5], arg[7] = arg[2]/osW*csW, arg[3]/osH*csH, arg[4]/osW*csW, arg[5]/osH*csH, (arg[7] or 1)/osW*csW return DrawText(unpack(arg)) end local isTimerVisible = false function displayCounter() dxDrawText("Your vehicle will change in: "..count, 237 + 1, 644 + 1, 811 + 1, 685 + 1, tocolor(0, 0, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) dxDrawText("Your vehicle will change in: "..count, 237, 644, 811, 685, tocolor(255, 162, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) -- foreground end function showCounter(Time) if Time then count = Time counting = setTimer(function() count = count - 1 end,1000,count) if not isTimerVisible then addEventHandler("onClientRender",root,displayCounter) isTimerVisible = true end else if isTimer(counting) then killTimer(counting) end removeEventHandler("onClientRender",root,displayCounter) isTimerVisible = false end end addEvent("showCounter",true) addEventHandler("showCounter",resourceRoot,showCounter) Server : local Time = 15 function onRoundStart(state) if state == "Running" then changeVeh() changeTimer = setTimer(changeVeh,Time*1000,0) elseif state == "PostFinish" or state == "TimesUp" or state == "EveryoneFinished" or state == "SomeoneWon" or state == "ResourceStopping" or state == "NoMap" or state == "LoadingMap" then if isTimer(changeTimer) then killTimer(changeTimer) end triggerClientEvent("showCounter",resourceRoot,false) end end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root,onRoundStart) function onRacerWasted() outputChatBox(getPlayerName(source).." died.") triggerClientEvent(source,"showCounter",resourceRoot,false) end addEvent("onPlayerRaceWasted",true) addEventHandler("onPlayerRaceWasted",root,onRacerWasted) function changeVeh() for _,plr in ipairs(getElementsByType("player")) do if not isPedDead(plr) then triggerClientEvent(plr,"showCounter",resourceRoot,Time) 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 end But my version dont't restart after map loading and sometimes crash what is wrong with it ? Edited August 24, 2016 by Guest Link to comment
Tails Posted August 14, 2016 Share Posted August 14, 2016 Maybe try and fix it on your own. This will probably be useful to you: https://wiki.multitheftauto.com/wiki/Resource:Race Link to comment
mores2 Posted August 14, 2016 Share Posted August 14, 2016 Thank you for your hint Do you think should I start make client start from zero ? Link to comment
mores2 Posted August 14, 2016 Share Posted August 14, 2016 This counter (client) is compatible with main script but I still don't have idea how to restart it after map loading because this wiki article dont say me enought 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 < 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) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) server works as should be 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) Link to comment
mores2 Posted August 17, 2016 Share Posted August 17, 2016 who can solve my problem ? it is important for me Link to comment
mores2 Posted August 19, 2016 Share Posted August 19, 2016 We are close to finish it Please guys only what I want is to make the client to restart always after map loading Link to comment
mores2 Posted August 21, 2016 Share Posted August 21, 2016 I hope on this forum exist a man who can do it Link to comment
Captain Cody Posted August 21, 2016 Share Posted August 21, 2016 Is the issue you are having now the same issue that you originally posted this thread for? Link to comment
mores2 Posted August 21, 2016 Share Posted August 21, 2016 You know man, always ok but (couter) which means client dont restarting after map loading and yeah it is the same problem The client should work like server ( main script ) it's always restarting after map loading ( 3,2,1,go ) and then Link to comment
Tails Posted August 21, 2016 Share Posted August 21, 2016 My script was working when I tested it. Link to comment
mores2 Posted August 22, 2016 Share Posted August 22, 2016 Yes your script works Tails but not as should be, becouse your script don't restart after map loading (if I remember it freeze), you can check this when map will change your script will do crazy things and (counter) is not punctual with main script, wait for (5 changes vehicle and you will see). You should wait few (vehicle changes) and change map few times to see what happens I think now you know about what I say Link to comment
mores3 Posted December 24, 2016 Share Posted December 24, 2016 Hello guys ! I have thought about this script a long time, and I decided to finish it. I can't do it alone, I've tried do this but something don't work. Could you Guys please make me a present for Christmas ? Just help me with this counter PS: Merry Christmas everyone Link to comment
pa3ck Posted December 24, 2016 Share Posted December 24, 2016 So since you created this topic (June) you still have no idea how to reset a counter? That means you are just lazy to do anything. Also a tip, when you forget your password on a forum account, try to use "Forgot my password" link to recover it, don't need to create different accounts every time you need help. 3 Link to comment
mores3 Posted December 24, 2016 Share Posted December 24, 2016 Simple01 I need to set a counter 1. it have start everytime after 3.2.1.GO <--- then it have to start and do it again on next map (very map) PS: pa3ck ,- I know about "Forgot my password" but i dont have access to my old email account Link to comment
Rataj Posted December 25, 2016 Share Posted December 25, 2016 (edited) Mores, little tip for next time: Learn to script, or find someone to do it for you. If you'll have problems with script (some piece of your code will not work), we are always here to help. But on the other side, I totally agree with pa3ck. Edited December 25, 2016 by Rataj Link to comment
mores3 Posted December 26, 2016 Share Posted December 26, 2016 I know it men at all. I only aks you guys for help . And I refereshed this old topic now because since june I haven't time for PC Link to comment
pa3ck Posted December 26, 2016 Share Posted December 26, 2016 (edited) Okay, this section is for helping scripters when they are stuck / need help. There's another section for requesting code. If I understand you correctly, you want a timer that changes vehicles every x seconds and resets when a map starts. Well, probably there is no magic behind it, there must be an event which calls the new maps, use that event to reset your timer. As far as I'm concerned, the timer part has already been posted in this topic. Edited December 26, 2016 by pa3ck Link to comment
mores3 Posted December 27, 2016 Share Posted December 27, 2016 ok give me name of this event or ( section in wiki about I can read ) Link to comment
pa3ck Posted December 27, 2016 Share Posted December 27, 2016 The event is in your gamemode, how could I know the name of it? Link to comment
Recommended Posts