Karuzo Posted March 15, 2014 Posted March 15, 2014 Hey Guys, so i wanted to trigger an event if the player is warped into a vehicle, but that doesn't really work how it should. It gives me an error that says that i triggered a client side event but i didn't add a client sided event. It outputs me "YAY" but i just won't be warped to the vehicle. Heres my serverside lua: function table.random ( theTable ) return theTable[math.random ( #theTable )] end local 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, 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 } addEventHandler("onResourceStart", resourceRoot, function() local players = getElementsByType ( "player" ) for pls,thePlayer in ipairs(players) do veh = createVehicle(table.random(vehicleIDS), 3819,-1846.2,48.4, 0, 0) outputChatBox("YAY") fadeCamera(thePlayer, true) local warp = warpPedIntoVehicle(thePlayer,veh) if warp == true then outputChatBox("yayyyyyyyyyywarp") triggerClientEvent(thePlayer,"Spawned", root) end end end) Clientsided event part : function SpawnedEvent() outputChatBox("YAYTRIGGER") setTimer(Spawned,1000,-1) addEventHandler("onClientRender", root, Drawing) end addEvent("Spawned",true) addEventHandler("Spawned",root, SpawnedEvent)
Castillo Posted March 15, 2014 Posted March 15, 2014 That's because the server side is loaded before the client side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Karuzo Posted March 15, 2014 Author Posted March 15, 2014 Ah, now it outputs "yaayyywarp" , but it still gives me the error as i said above, and i'm still not in the car. and for some reasons i get network trouble ??
Castillo Posted March 15, 2014 Posted March 15, 2014 It's a bug. http://bugs.mtasa.com/view.php?id=7855 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Karuzo Posted March 15, 2014 Author Posted March 15, 2014 Oh. But is there a work-around to do this ?
Castillo Posted March 15, 2014 Posted March 15, 2014 Tried using a timer? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Saml1er Posted March 15, 2014 Posted March 15, 2014 (edited) Try debugging it btw I once experienced the same problem. I don't remember exactly how I got it fixed but MAYBE try replacing line 2 with this: return theTable[math.random (1, #theTable )] and line 24 with this: triggerClientEvent(thePlayer,"Spawned", thePlayer) Edited March 15, 2014 by Guest
Castillo Posted March 15, 2014 Posted March 15, 2014 -- server side: function table.random ( theTable ) return theTable[math.random ( #theTable )] end local 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, 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 } addEvent ( "giveVehicle", true ) addEventHandler ( "giveVehicle", resourceRoot, function ( ) local veh = createVehicle ( table.random ( vehicleIDS ), 3819, -1846.2, 48.4, 0, 0 ) outputChatBox ( "YAY" ) fadeCamera ( source, true ) local warp = warpPedIntoVehicle ( source, veh ) if ( warp == true ) then outputChatBox ( "yayyyyyyyyyywarp" ) triggerClientEvent ( source, "Spawned", root ) end end ) -- client side. addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) triggerServerEvent ( "giveVehicle", localPlayer ) end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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