Jump to content

How make it only client-side


FuriouZ

Recommended Posts

Posted

Hello,help me with this,i need to convert it only client-side..

Client:

local delayvalue = false 
datmarker = createMarker (4805.2998,-1599.5,20,"corona",5,12,7,77,153) 
  
  
  
  
function changeVehFunc ( hitPlayer, matchingDimension ) 
 if (matchingDimension and hitPlayer == localPlayer) then 
  if delayvalue == false then 
   triggerServerEvent("changeVeh", localPlayer) 
   delayvalue = true 
   setTimer(function () 
    delayvalue = false 
    end, 1500, 1) 
  end 
 end 
end 
  
  
  
addEventHandler("onClientMarkerHit", datmarker, changeVehFunc) 

Server:

vehicles = {602,545,496,517,401,410,518,600,527,436,589,580,419,439533,549,526,491,474,445,604,507,585,587,466,492,546,551,516,467,426,547,405,409,550,566,540,421,529,581,509,481,462,521,463,510,522,461,448,468,586,485,552,431,438,437,574,420,525,408,416,433,427,490,528,407,544,523,470,598,596,597,599,601,428,499,609,498,524,532,578,486,406,573,455,588,403,514,423,414,443,515,531,456,459,422,482,605,530,418,572,582,413,440,543,583,478,554,536,575,534,567,535,576,412,402,542,603,475,568,424,504,457,483,508,571,500,444,556,557,471,495,539,429,541,415,480,562,565,323,492,502,503,411,559,561,560,506,451,558,555,477,579,400,404,489,505,479,442,458} 
  
function changeVehicle (state) 
 if state == "Running" then 
  setTimer (function () 
    local players = getAlivePlayers () 
    for playerKey, playerValue in ipairs(players) do 
     setElementModel (getPedOccupiedVehicle(playerValue), vehicles[math.random(#vehicles)]) 
  
    end 
   end, 1000, 1) 
 end 
  
end 
addEvent("onRaceStateChanging", true) 
addEventHandler ("onRaceStateChanging", getRootElement (), changeVehicle) 
  
  
  
 function changePlayersVeh () 
 setElementModel (getPedOccupiedVehicle(source), vehicles[math.random(#vehicles)]) 
  
  
end 
addEvent("changeVeh", true) 
addEventHandler("changeVeh", getRootElement(), changePlayersVeh) 

Posted

it's not possible bk "getAlivePlayers ()" it's only server side. And there is a reason why it has server side to .

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

You can create your own function, you don't have to use the native one.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

Why the f* is it too hard to do this?

    local players = getElementsByType("player") 
    for playerKey, playerValue in pairs(players) do 
        if getElementHealth(playerValue)>0 then 
            setElementModel (getPedOccupiedVehicle(playerValue), vehicles[math.random(#vehicles)]) 
        end 
    end 

The rest is yours.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

Learn the basic first, instead of requesting scripting modifications (of work from other people).

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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...