Jump to content

Help me!


Anubhav

Recommended Posts

  
function giveCar ( thePlayer, commandName ) 
  
 if getElementType ( thePlayer ) == "player" then 
 local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
 local x, y, z = getElementPosition(thePlayer) 
 if isObjectInACLGroup ("user."..accName, aclGetGroup ("VIP")) then 
 local comet = createVehicle ( 480, x, y, z+0.5 ) 
 warpPlayerIntoVehicle ( thePlayer, comet ) 
  
else 
 outputChatBox("You are not a VIP.",thePlayer,255,60,60) 
 end 
 end 
 end 
  
addCommandHandler ( "pc", giveCar ) 
  

This is my code!

How should i add anti spam of cars and timer for spawning cars! I Am not soo good in scripting so please help me in it!!

Link to comment
waitTimer = {} 
waitTime = 5000 -- time in miliseconds 
function giveCar ( thePlayer, commandName ) 
    if getElementType ( thePlayer ) == "player" then 
    if (waitTimer[thePlayer]) then 
        return  
        -- add here outputChatBox if you want it! 
    end 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    local x, y, z = getElementPosition(thePlayer) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ("VIP")) then 
            local comet = createVehicle ( 480, x, y, z+0.5 ) 
            warpPlayerIntoVehicle ( thePlayer, comet ) 
            waitTimer[thePlayer]  = setTimer(waitTime, 1, function() end) 
        else 
            outputChatBox("You are not a VIP.",thePlayer,255,60,60) 
        end 
    end 
 end 
addCommandHandler ( "pc", giveCar ) 

I know you can use getTickCount but this is easyer

Link to comment

Didn't test though.

local timings = { } 
  
function giveCar ( thePlayer, commandName ) 
  if getElementType ( thePlayer ) == "player" then 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ("VIP")) then 
      local currentTime = getTickCount() -- get current time 
      local playerTime = timings[thePlayer] -- get saved player's time 
      if playerTime then -- if the time had been saved for the player 
        local diff = currentTime - playerTime -- find the difference of the time 
        if diff < 25000 then -- if less than 25 seconds passed 
          outputChatBox("25 seconds haven't passed yet",thePlayer) 
          return false -- stop executing the function 
        end 
      end 
      local comet = createVehicle ( 480, x, y, z+0.5 ) 
      warpPlayerIntoVehicle ( thePlayer, comet ) 
      timings[thePlayer] = getTickCount() -- save current player time 
    else 
      outputChatBox("You are not a VIP.",thePlayer,255,60,60) 
    end 
  end 
end 
addCommandHandler ( "pc", giveCar ) 

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