Jump to content

onPlayerPickUpRacePickup individual players, how ???


Recommended Posts

Posted

The script works well, but i tried this with a help of few players, hunters variable keeps counting and adding for all the players, how can i make it individual ?

-- Script made by -ffs-AbodyRulez specially for ffs simulation servers -- 
  
local hunters = 0 
  
function HunterCounts(pickupID, pickupType, vehicleModel) 
        if pickupType == "vehiclechange" and vehicleModel == 425 then  
            hunters = hunters + 1 
            if hunters == 1 then 
                outputChatBox(getPlayerName(source).."#FFFFFFreached Hunter#FF0000 "..hunters.." #FFFFFFtime",_,255,255,255,true) 
            elseif hunters > 1 then 
                outputChatBox(getPlayerName(source).."#FFFFFFreached Hunter#FF0000 "..hunters.." #FFFFFFtimes",_,255,255,255,true) 
            end 
        end  
end 
addEventHandler("onPlayerPickUpRacePickup", root, HunterCounts) 
  
-- Script made by -ffs-AbodyRulez specially for ffs simulation servers -- 
  

Posted

bk it's server sided = all player willhave the same "hunters" variable.

To make this you sould use table or accountData

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted
  
local hunters = {} 
  
function HunterCounts(pickupID, pickupType, vehicleModel) 
        if pickupType == "vehiclechange" and vehicleModel == 425 then 
            hunters[getPlayerName(source)] = ( hunters[getPlayerName(source)] or 0 )+1 
            if hunters[getPlayerName(source)] == 1 then 
                outputChatBox(getPlayerName(source).."#FFFFFFreached Hunter#FF0000 ".hunters[getPlayerName(source)].." #FFFFFFtime",_,255,255,255,true) 
            elseif hunters > 1 then 
                outputChatBox(getPlayerName(source).."#FFFFFFreached Hunter#FF0000 "..hunters[getPlayerName(source)].." #FFFFFFtimes",_,255,255,255,true) 
            end 
        end  
end 
addEventHandler("onPlayerPickUpRacePickup", root, HunterCounts) 
  
-- Script made by -ffs-AbodyRulez specially for ffs simulation servers -- 
  
  

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

  • Moderators
Posted

The user data should be the table key and not his nick. Nicks can be changed you know.

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

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

it's just an exampel for the simplest way , it should be changed to account data to save them on exit.

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

Thats still an bad idea for putting it on the nickname, like when he will change the name the datakey will be lost like IIYAMA said, you can better set it on the player element, since the player element will last forever when he's connected, and when he's disconnected he will be removed from the table.

And it's simpler than the getPlayerName function :P

Sometimes I dream about cheese

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