Jump to content

marker's


abdalbaset

Recommended Posts

  
marker =createMarker(-23.4414,-55.150,1002.5468,"cylinder", 1.5, 250,0,0, 255 ) 
setElementInterior( marker,6,-23.4414,-55.150,1003.5468) 
  
function output() 
  
outputChatBox ( "*To Rob this shop use /robshop", getRootElement(), 255, 0, 0, true ) 
  
end 
addEventHandler( "onMarkerHit", marker, output ) 
  
  
function rober(thePlayer, matchingDimension) 
    if isElementWithinMarker(thePlayer, marker) then 
     outputChatBox ( "robbery attempt success", getRootElement(), 0, 255, 0, true ) 
    givePlayerMoney (thePlayer , 15000) 
    setPlayerWantedLevel (  thePlayer, 6 )  
    destroyElement ( marker ) 
 else 
    outputChatBox("get in the marker to rob this shop", thePlayer, 255, 0, 0) 
 end 
end 
addCommandHandler("robshop", rober) 
  
  
  
  

here is my code i want the player to be able to rob the shop once every 5min,

Link to comment

Use something like a timer. Try this:

(not tested)

marker =createMarker(-23.4414,-55.150,1002.5468,"cylinder", 1.5, 250,0,0, 255 ) 
setElementInterior( marker,6,-23.4414,-55.150,1003.5468) 
  
function output() 
  
outputChatBox ( "*To Rob this shop use /robshop", getRootElement(), 255, 0, 0, true ) 
  
end 
addEventHandler( "onMarkerHit", marker, output ) 
  
cooldown = {} 
timeleft = {} 
  
function rober(thePlayer, matchingDimension) 
if (not isTimer(cooldown[thePlayer]) then 
    if isElementWithinMarker(thePlayer, marker) then 
     outputChatBox ( "robbery attempt success", getRootElement(), 0, 255, 0, true ) 
    givePlayerMoney (thePlayer , 15000) 
    setPlayerWantedLevel (  thePlayer, 6 ) 
cooldown[thePlayer] = setTimer(function () end, 10000, 1) 
    destroyElement ( marker ) 
 else 
    outputChatBox("get in the marker to rob this shop", thePlayer, 255, 0, 0) 
 end 
else 
left, _, _ = getTimerDetails(cooldown[thePlayer]) 
timeleft[thePlayer] = math.floor(left) 
    outputChatBox("You need to wait 10s between each rob! time left: "..timeleft[thePlayer].."s", thePlayer, 255, 0, 0) 
end 
end 
addCommandHandler("robshop", rober) 

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