Jump to content

What wrong?


youpit

Recommended Posts

Hi all i tried to make a script but its dont work what wrong ?

Server-side

   addEventHandler ("onClientVehicleRespawn",nil,muh, 
     
    function (fxAddGlass) 
     local account = getPlayerAccount(fxAddGlass) 
     if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then 
       
      triggerClientEvent (hitPlayer,"muh",fxAddGlass) 
     else 
      outputChatBox ("Sorry you are not prenuim !",fxAddGlass) 
     
     end 
    end) 
     
     

Client-side

function muh () 
    for k, v in ipairs(getElementsByType("vehicle")) do 
          
        local x, y, z = getElementPosition(v) 
  
        local c = math.random(0, 126) 
  
     
  
         
        fxAddGlass(x, y, z, math.random(0, 255), math.random(0, 255), math.random(0, 255), math.random(0, 255), 0.08, 1) 
     
  
  
             end 
     
end 
  
addEvent ( "muh", true ) 
addEventHandler("muh",root,muh) 
  

Link to comment

What wrong ???????? All :mrgreen:

the event "onClientVehicleRespawn" is client side.

Anyway Try it :

ServerSide

  
function AdminGlass (player) 
 local theAccount=getPlayerAccount(player) 
    if theAccount then 
    local accountName = getAccountName(theAccount) 
    if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then 
    triggerClientEvent(player,"addGlass",getRootElement()) 
        end      
end 
end 
function checkAdmin() 
setTimer(AdminGlass,100,1,source) 
end 
addEventHandler("onPlayerSpawn",getRootElement(),checkAdmin) 
  
  

ClientSide

  
addEvent ( "addGlass", true ) 
function createGlass() 
 local vehicle = getPedOccupiedVehicle (getLocalPlayer()) 
  x,y,z=getElementPosition(vehicle)  
  if vehicle then 
fxAddGlass(x,y,z+1,math.random(10, 255),math.random(10, 255),math.random(10, 255),255,0.1,1) 
end 
end 
setTimer ( createGlass, 50, 0 ) 
addEventHandler("addGlass",getRootElement(),createGlass) 
  

Link to comment

Althought Hunterix helped you with your script,

I suggest you reading MTAs wiki. Like

getPlayerAccount( ) 
--need a player value 

Also if you put

for k, v in ipairs(getElementsByType("vehicle")) do 
--There it will return a table with all the vehicles at the server 

So try watching function's arguments and what it return.

Sorry for my bad english.

Link to comment

That script would make the server crash, if not, then the server would have an unstable bandwidth and if not that then it would have unwanted effects because triggerClientEvent consumes server bandwidth resources. The way to make it is using setElementData, getElementData and onClientRender event.

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