#Paper Posted June 12, 2011 Posted June 12, 2011 setElementModel bad argument: 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, 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 setRandomVehicle(theVehicle) setElementModel(theVehicle, math.random(math.min(#vehicleIDS), math.max(#vehicleIDS)) end function onSpawn() setRandomVehicle(getPedOccupiedVehicle(source)) end addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 what are you trying to do here? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted June 12, 2011 Posted June 12, 2011 function onSpawn() setRandomVehicle(getPedOccupiedVehicle(source)) end addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) how do u expect the player to be in a vehicle when he spawns? addEventHandler('onVehicleEnter', root, function(player, seat) if seat == 0 then setRandomVehicle(source) end end ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 ooohhhh ok, your right JR10 My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
#Paper Posted June 12, 2011 Author Posted June 12, 2011 function onSpawn() setRandomVehicle(getPedOccupiedVehicle(source)) end addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) how do u expect the player to be in a vehicle when he spawns? addEventHandler('onVehicleEnter', root, function(player, seat) if seat == 0 then setRandomVehicle(source) end end ) wtf? My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 Did you tried it? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted June 12, 2011 Posted June 12, 2011 Can you tell us what you want? Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 Ya, We're tryin to help you and your saying "WTF" My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
#Paper Posted June 12, 2011 Author Posted June 12, 2011 Ya, We're tryin to help you and your saying "WTF" i need this function for the race mode... i don't think that when the player spawns in the vehicle the onVehicleEnter event will be called... My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
Jaysds1 Posted June 12, 2011 Posted June 12, 2011 ooooh, ok then why didn't you say so then? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
#Paper Posted June 12, 2011 Author Posted June 12, 2011 sry, any idea for fix? My skype: skiper964 I helped you? Help me! ^^ Help me bro! ^^
BinSlayer1 Posted June 12, 2011 Posted June 12, 2011 Ya, We're tryin to help you and your saying "WTF" i need this function for the race mode... i don't think that when the player spawns in the vehicle the onVehicleEnter event will be called... it will, and it's sure as hell better to use onVehicleEnter instead of onPlayerSpawn for the 'race' gamemode. When you die and respawn in race, your player actually doesn't die... Its position will be somewhere up in the sky so he will never "respawn" again hence onPlayerSpawn won't be triggered everytime you respawn in race and another problem i see is that math.min(#vehicleIDS) (and math.max) these math functions need a few numbers out of which they will decide which one is min or max. you're only passing #vehicleIDS which is ONE number, not two. I'm not entirely sure, but this is what I understand from here: http://lua-users.org/wiki/MathLibraryTutorial So you should think of another way to get that random number.. How about this one? function setRandomVehicle(theVehicle) setElementModel(theVehicle, vehicleIDS[math.random(1,#vehicleIDS)] end
Wojak Posted June 12, 2011 Posted June 12, 2011 Ya, We're tryin to help you and your saying "WTF" i need this function for the race mode... i don't think that when the player spawns in the vehicle the onVehicleEnter event will be called... it will, and it's sure as hell better to use onVehicleEnter instead of onPlayerSpawn for the 'race' gamemode. When you die and respawn in race, your player actually doesn't die... Its position will be somewhere up in the sky so he will never "respawn" again hence onPlayerSpawn won't be triggered everytime you respawn in race hmm, so how come my script, that displays player spawn on deathmessage works every time? (it uses event onPlayerSpawn) you can see it on this video on 07:12: create your teleports and interiors in MTA map editor want more excitment in your race map? - add a killer bot you may also add some peds (NPC) - CARMAGEDDON STYLE! 2paq MTA:SA Race Server
BinSlayer1 Posted June 12, 2011 Posted June 12, 2011 Yes it appears you're right. Perhaps the only issue remains his setRandomVehicle function
karlis Posted June 13, 2011 Posted June 13, 2011 problem is that you don't actually call the ids, but just keys for the id's. so instead of getting id 602 for example you get id 1. also you dont need math.max or math.min, those functions just return max/min value passed, so its a waste with 1 argument. fix: function setRandomVehicle(theVehicle) setElementModel(theVehicle, vehicleIDS[math.random(#vehicleIDS)]) end [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
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