Jump to content

Constantly give money when on marker.


DRW

Recommended Posts

Hello, I'm creating a script that makes a player in a specific ACL group to constantly get money every 2 seconds when on marker until the player leaves it. Now, the player in the ACL gets 500$ but just every time he hits the marker, not when he is within the marker. This is what I've got:

BaseAlianza = createMarker (2794,-2418,12.6,"cylinder",5,255,0,0,255) 
BaseAlianzaR = createColRectangle (2784,-2442, 50,50) 
BaseAlianzaRC = createRadarArea (2784,-2442, 50,50,100,100,100,255) 
  
function toqueMarkerA (hitElement) 
    if isObjectInACLGroup("user."..getAccountName( getPlayerAccount(hitElement) ), aclGetGroup("Anarquia")) then 
givePlayerMoney (hitElement,500) 
  
end 
end 
  
function toqueRectA (hitElement) 
    if isObjectInACLGroup("user."..getAccountName( getPlayerAccount(hitElement) ), aclGetGroup("Anarquia")) then 
outputChatBox ("¡UN ANARQUISTA HA ENTRADO!", getRootElement()) 
end 
end 
  
addEventHandler ("onMarkerHit", BaseAlianza, toqueMarkerA) 
addEventHandler ("onColShapeHit", BaseAlianzaR, toqueRectA) 

Link to comment
local Time = 2 -- in seconds 
local Money = 500 
local BaseAlianza = createMarker (2794,-2418,12.6,"cylinder",5,255,0,0,255) 
  
setTimer(function() 
    for _,player in ipairs(getElementsByType("player")) do 
        if isElementWithinMarker(player,BaseAlianza) then 
            if isObjectInACLGroup("user."..getAccountName( getPlayerAccount(player) ), aclGetGroup("Anarquia")) then 
                givePlayerMoney (player,Money)  
            end 
        end 
    end 
end,Time*1000,0) 

Link to comment
So you want to do that if player enters the marker and he will wait there 2 seconds he will get money or what?

Something like that, every 2 seconds he passes into the marker he will get 500$, so when 4 seconds had passed, he would have 1000$ more, and when 6 seconds had passed, 1500$, etc.

Link to comment
local Time = 2 -- in seconds 
local Money = 500 
local BaseAlianza = createMarker (2794,-2418,12.6,"cylinder",5,255,0,0,255) 
  
setTimer(function() 
    for _,player in ipairs(getElementsByType("player")) do 
        if isElementWithinMarker(player,BaseAlianza) then 
            if isObjectInACLGroup("user."..getAccountName( getPlayerAccount(player) ), aclGetGroup("Anarquia")) then 
                givePlayerMoney (player,Money)  
            end 
        end 
    end 
end,Time*1000,0) 

Perfect, thanks!

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