Jump to content

Random Vehiclepickup


Jessie

Recommended Posts

Ok, I've managed to change the pickup vehicle model and the text over it.

-- add this to: race_client.lua:

addEvent("changePickupText",true) 
addEventHandler("changePickupText",root, 
    function (ID, newModel) 
        for index, pickup in pairs(g_Pickups) do 
            if (pickup.type == "vehiclechange" and pickup.id == ID) then 
                pickup.vehicle = newModel 
                pickup.label:text(getVehicleNameFromModel(newModel)) 
            end 
        end 
    end 
) 

-- edit this in race_server.lua:

carIDS = { 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, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 470, 598, 499, 588, 609, 403, 498, 514, 524, 423, 532, 414, 578, 443, 486, 515, 531, 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, 441, 564, 568, 424, 504, 495, 457, 483, 508, 71, 500, 429, 411, 541, 559, 415, 61, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 594 } 
  
addEvent('onPlayerPickUpRacePickup') 
addEvent('onPlayerPickUpRacePickupInternal', true) 
addEventHandler('onPlayerPickUpRacePickupInternal', g_Root, 
    function(pickupID, respawntime) 
        if checkClient( false, source, 'onPlayerPickUpRacePickupInternal' ) then return end 
        local pickup = g_Pickups[table.find(g_Pickups, 'id', pickupID)] 
        local vehicle = g_Vehicles[source] 
        if not pickup or not vehicle then return end 
        if respawntime and tonumber(respawntime) >= 50 then 
            table.insert(unloadedPickups, pickupID) 
            clientCall(g_Root, 'unloadPickup', pickupID) 
            TimerManager.createTimerFor("map"):setTimer(ServerLoadPickup, tonumber(respawntime), 1, pickupID) 
        end 
        if pickup.type == 'repair' then 
            fixVehicle(vehicle) 
        elseif pickup.type == 'nitro' then 
            addVehicleUpgrade(vehicle, 1010) 
        elseif pickup.type == 'vehiclechange' then 
            if getElementModel(vehicle) ~= tonumber(pickup.vehicle) then 
                clientCall(source, 'alignVehicleWithUp') 
                setVehicleID(vehicle, pickup.vehicle) 
                setVehiclePaintjobAndUpgrades(vehicle, pickup.paintjob, pickup.upgrades) 
                clientCall(source, 'vehicleChanging', g_MapOptions.classicchangez, tonumber(pickup.vehicle)) 
                setTimer(function (ID) 
                    local pickup = g_Pickups[table.find(g_Pickups, 'id', ID)] 
                    pickup.vehicle = carIDS[math.random(#carIDS)] 
                    triggerClientEvent("changePickupText",root,pickup.id,pickup.vehicle) 
                end, 60000, 1, pickup.id) 
            end 
        end 
        triggerEvent('onPlayerPickUpRacePickup', source, pickupID, pickup.type, pickup.vehicle) 
    end 
) 

Link to comment
Ok, I've managed to change the pickup vehicle model and the text over it.

-- add this to: race_client.lua:

addEvent("changePickupText",true) 
addEventHandler("changePickupText",root, 
    function (ID, newModel) 
        for index, pickup in pairs(g_Pickups) do 
            if (pickup.type == "vehiclechange" and pickup.id == ID) then 
                pickup.vehicle = newModel 
                pickup.label:text(getVehicleNameFromModel(newModel)) 
            end 
        end 
    end 
) 

-- edit this in race_server.lua:

carIDS = { 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, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 470, 598, 499, 588, 609, 403, 498, 514, 524, 423, 532, 414, 578, 443, 486, 515, 531, 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, 441, 564, 568, 424, 504, 495, 457, 483, 508, 71, 500, 429, 411, 541, 559, 415, 61, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 594 } 
  
addEvent('onPlayerPickUpRacePickup') 
addEvent('onPlayerPickUpRacePickupInternal', true) 
addEventHandler('onPlayerPickUpRacePickupInternal', g_Root, 
    function(pickupID, respawntime) 
        if checkClient( false, source, 'onPlayerPickUpRacePickupInternal' ) then return end 
        local pickup = g_Pickups[table.find(g_Pickups, 'id', pickupID)] 
        local vehicle = g_Vehicles[source] 
        if not pickup or not vehicle then return end 
        if respawntime and tonumber(respawntime) >= 50 then 
            table.insert(unloadedPickups, pickupID) 
            clientCall(g_Root, 'unloadPickup', pickupID) 
            TimerManager.createTimerFor("map"):setTimer(ServerLoadPickup, tonumber(respawntime), 1, pickupID) 
        end 
        if pickup.type == 'repair' then 
            fixVehicle(vehicle) 
        elseif pickup.type == 'nitro' then 
            addVehicleUpgrade(vehicle, 1010) 
        elseif pickup.type == 'vehiclechange' then 
            if getElementModel(vehicle) ~= tonumber(pickup.vehicle) then 
                clientCall(source, 'alignVehicleWithUp') 
                setVehicleID(vehicle, pickup.vehicle) 
                setVehiclePaintjobAndUpgrades(vehicle, pickup.paintjob, pickup.upgrades) 
                clientCall(source, 'vehicleChanging', g_MapOptions.classicchangez, tonumber(pickup.vehicle)) 
                setTimer(function (ID) 
                    local pickup = g_Pickups[table.find(g_Pickups, 'id', ID)] 
                    pickup.vehicle = carIDS[math.random(#carIDS)] 
                    triggerClientEvent("changePickupText",root,pickup.id,pickup.vehicle) 
                end, 60000, 1, pickup.id) 
            end 
        end 
        triggerEvent('onPlayerPickUpRacePickup', source, pickupID, pickup.type, pickup.vehicle) 
    end 
) 

Thx!

But, when i start my Local server. and i put the files in the map. + the lines in meta etc it says: could not find race_server.lua

do you know what that error is coming ?

Link to comment

<meta> 
    <script src="race_server.lua" type="server"></script> 
    <script src="race_client.lua" type="client"></script> 
    <info gamemodes="race" type="map" name="[DD]MAPNAME" author="Jessie" version="1.0.0"></info> 
    <map src="[DD]radiuslol.map" dimension="0"></map> 
    <settings> 
        <setting name="#skins" value='[ "cj" ]'></setting> 
        <setting name="#maxplayers" value="[ 128 ]"></setting> 
        <setting name="#gamespeed" value="[ 1 ]"></setting> 
        <setting name="#ghostmode" value='[ "false" ]'></setting> 
        <setting name="#time" value="12:0"></setting> 
        <setting name="#vehicleweapons" value='[ "false" ]'></setting> 
        <setting name="#minplayers" value="[ 0 ]"></setting> 
        <setting name="#weather" value="[ 0 ]"></setting> 
        <setting name="#gravity" value="[ 0.008000 ]"></setting> 
        <setting name="#waveheight" value="[ 0 ]"></setting> 
        <setting name="#respawntime" value="[ 5 ]"></setting> 
        <setting name="#locked_time" value="[ false ]"></setting> 
        <setting name="#duration" value="[ 1800 ]"></setting> 
        <setting name="#respawn" value='[ "timelimit" ]'></setting> 
    </settings> 
</meta> 

https://wiki.multitheftauto.com/wiki/Meta.xml

In next time paste meta in code.

Link to comment

You need put into race gm.( This code )

Ok, I've managed to change the pickup vehicle model and the text over it.

-- add this to: race_client.lua:

addEvent("changePickupText",true) 
addEventHandler("changePickupText",root, 
    function (ID, newModel) 
        for index, pickup in pairs(g_Pickups) do 
            if (pickup.type == "vehiclechange" and pickup.id == ID) then 
                pickup.vehicle = newModel 
                pickup.label:text(getVehicleNameFromModel(newModel)) 
            end 
        end 
    end 
) 

-- edit this in race_server.lua:

carIDS = { 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, 485, 552, 431, 438, 437, 574, 420, 525, 408, 416, 596, 433, 597, 427, 599, 490, 432, 528, 601, 407, 428, 544, 470, 598, 499, 588, 609, 403, 498, 514, 524, 423, 532, 414, 578, 443, 486, 515, 531, 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, 441, 564, 568, 424, 504, 495, 457, 483, 508, 71, 500, 429, 411, 541, 559, 415, 61, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503, 579, 400, 404, 489, 505, 479, 442, 458, 594 } 
  
addEvent('onPlayerPickUpRacePickup') 
addEvent('onPlayerPickUpRacePickupInternal', true) 
addEventHandler('onPlayerPickUpRacePickupInternal', g_Root, 
    function(pickupID, respawntime) 
        if checkClient( false, source, 'onPlayerPickUpRacePickupInternal' ) then return end 
        local pickup = g_Pickups[table.find(g_Pickups, 'id', pickupID)] 
        local vehicle = g_Vehicles[source] 
        if not pickup or not vehicle then return end 
        if respawntime and tonumber(respawntime) >= 50 then 
            table.insert(unloadedPickups, pickupID) 
            clientCall(g_Root, 'unloadPickup', pickupID) 
            TimerManager.createTimerFor("map"):setTimer(ServerLoadPickup, tonumber(respawntime), 1, pickupID) 
        end 
        if pickup.type == 'repair' then 
            fixVehicle(vehicle) 
        elseif pickup.type == 'nitro' then 
            addVehicleUpgrade(vehicle, 1010) 
        elseif pickup.type == 'vehiclechange' then 
            if getElementModel(vehicle) ~= tonumber(pickup.vehicle) then 
                clientCall(source, 'alignVehicleWithUp') 
                setVehicleID(vehicle, pickup.vehicle) 
                setVehiclePaintjobAndUpgrades(vehicle, pickup.paintjob, pickup.upgrades) 
                clientCall(source, 'vehicleChanging', g_MapOptions.classicchangez, tonumber(pickup.vehicle)) 
                setTimer(function (ID) 
                    local pickup = g_Pickups[table.find(g_Pickups, 'id', ID)] 
                    pickup.vehicle = carIDS[math.random(#carIDS)] 
                    triggerClientEvent("changePickupText",root,pickup.id,pickup.vehicle) 
                end, 60000, 1, pickup.id) 
            end 
        end 
        triggerEvent('onPlayerPickUpRacePickup', source, pickupID, pickup.type, pickup.vehicle) 
    end 
) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...