-ffs-AbodyRulez Posted August 16, 2013 Posted August 16, 2013 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 --
bandi94 Posted August 16, 2013 Posted August 16, 2013 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 :
-ffs-AbodyRulez Posted August 16, 2013 Author Posted August 16, 2013 And how am i supposed to do that :3
bandi94 Posted August 16, 2013 Posted August 16, 2013 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 :
Moderators IIYAMA Posted August 16, 2013 Moderators Posted August 16, 2013 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 Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
bandi94 Posted August 17, 2013 Posted August 17, 2013 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 :
denny199 Posted August 17, 2013 Posted August 17, 2013 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 Sometimes I dream about cheese
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now