AnnaBelle Posted April 13, 2017 Share Posted April 13, 2017 Gain double experience over the weekend, Only at the weekend. setElementData(killer,"murders",getElementData(killer,"murders")+1) local experiences = math.random(200,300) setElementData(killer,"experience",getElementData(killer,"experience") + experiences) Ex: [INFO] You Killed: ^NewYork || Weapon: Sniper || Distance: 200m || Exp: 286 x2 Link to comment
Bonsai Posted April 13, 2017 Share Posted April 13, 2017 https://wiki.multitheftauto.com/wiki/GetRealTime weekday: 0-6 since Sunday. Link to comment
AnnaBelle Posted April 13, 2017 Author Share Posted April 13, 2017 Yes I know this function but I do not know how to do Link to comment
#BrosS Posted April 13, 2017 Share Posted April 13, 2017 (edited) time = getRealTime() week = time.weekday if week == 5 then lolololo' -- i don't know what to do i think 5 is friday i guess Edited April 13, 2017 by #BrosS Link to comment
AnnaBelle Posted April 13, 2017 Author Share Posted April 13, 2017 Yes, but where will you double your experience? Link to comment
Mr.Loki Posted April 13, 2017 Share Posted April 13, 2017 local modifier = 1 local day = getRealTime().weekday if day == 0 or day == 6 then -- 0 = sun 6 = sat modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience",getElementData(killer,"experience") + experiences) Link to comment
AnnaBelle Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) Has to appear in the chat when this event is active outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m #FFFFFF || Exp: #32FF32"..experiences.."#F7FE2E 2x",killer,0,128,255,true) like that I want the 2x message to appear on the weekend, during the week it does not appear Edited April 13, 2017 by AnnaBelle Link to comment
NeXuS™ Posted April 13, 2017 Share Posted April 13, 2017 (edited) local modifier = 1 local day = getRealTime().weekday if day == 0 or day == 6 then -- 0 = sun 6 = sat outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m #FFFFFF || Exp: #32FF32"..experiences.."#F7FE2E 2x",killer,0,128,255,true) modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience",getElementData(killer,"experience") + experiences) I suppose you want this. Edited April 13, 2017 by NeXuS™ Link to comment
AnnaBelle Posted April 14, 2017 Author Share Posted April 14, 2017 outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m #FFFFFF || Exp: #32FF32"..experiences.."#F7FE2E 2x",killer,0,128,255,true) [2017-04-15 21:00:53] ERROR: [DayZ]\DayZ\spawn.lua:242: bad argument #1 to 'floor' (number expected, got nil) math.floor Should not give error because I use this line to show on the player's local distance, weapon, experience local modifier = 1 local day = getRealTime().weekday if day == 0 or day == 6 then -- 0 = sun 6 = sat modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience",getElementData(killer,"experience") + experiences) Every time I kill the grenade, I get bugged on the server, because of this function Link to comment
AnnaBelle Posted April 14, 2017 Author Share Posted April 14, 2017 I managed to fix it, except the message that appears Link to comment
DNL291 Posted April 14, 2017 Share Posted April 14, 2017 What 'Distancia' is returning? Where is that defined? Link to comment
AnnaBelle Posted April 14, 2017 Author Share Posted April 14, 2017 getDistanceBetweenPoints3D Link to comment
AnnaBelle Posted April 14, 2017 Author Share Posted April 14, 2017 Every time the player kills himself on the grenade a bug happens Link to comment
DNL291 Posted April 15, 2017 Share Posted April 15, 2017 (edited) It looks like 'Distancia' is returning nil for some reason. You'll need to debug your code until you find where it's wrong, if you don't want to show your code here. 9 hours ago, AnnaBelle said: Every time the player kills himself on the grenade a bug happens Compare killer with source and make sure the killer isn't the player who died (I'm assuming you're using it inside onPlayerWasted event). Edited April 15, 2017 by DNL291 Link to comment
AnnaBelle Posted April 15, 2017 Author Share Posted April 15, 2017 Just wait, I'll modify it and test it if killer then if not getElementData(source,"bandit") then addPlayerStats (killer,"humanity",math.random(-2500,-1000)) else addPlayerStats (killer,"humanity",math.random(1000,2500)) end setElementData(killer,"murders",getElementData(killer,"murders")+1) local modifier = 1 local day = getRealTime().weekday if day == 0 then modifier = 3 elseif day == 6 then -- 0 = sun 6 = sat modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience",getElementData(killer,"experience") + experiences) if getElementData(killer,"humanity") < 0 then setElementData(killer,"bandit",true) end if getElementData(source,"bandit") == true then setElementData(killer,"banditskilled",getElementData(killer,"banditskilled")+1) end if headshot == true then setElementData(killer,"headshots",getElementData(killer,"headshots")+1) end local xX,yY,zZ = getElementPosition(source) local xk,yk,zk = getElementPosition(killer) local Distancia = getDistanceBetweenPoints3D(xX,yY,zZ,xk,yk,zk) outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m #FFFFFF || Exp: #32FF32"..experiences,killer,0,128,255,true) outputChatBox("[INFO]#FFFFFF Você foi morto por: #32FF32"..getPlayerName(killer):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..math.floor(Distancia).."m",source,0,128,255,true) setTimer(function(source,killer)end,6000,1,source) triggerClientEvent("onRollMessageStart",getRootElement(),getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." foi morto por "..getPlayerName(killer):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x',''),255,255,255, "died") else triggerClientEvent("onRollMessageStart",getRootElement(),getPlayerName(source):gsub('#%x%x%x%x%x%x',''):gsub('#%x%x%x%x%x%x','').." morreu.",255,255,255, "died") end The whole function is this, but there is nothing wrong with my seeing. Link to comment
DNL291 Posted April 15, 2017 Share Posted April 15, 2017 Try this: if killer and (getElementType(killer) == "player") and killer ~= source then if not getElementData(source,"bandit") then addPlayerStats (killer,"humanity",math.random(-2500,-1000)) else addPlayerStats (killer,"humanity",math.random(1000,2500)) end setElementData(killer,"murders", (getElementData(killer,"murders") or 0) +1) local modifier = 1 local day = getRealTime().weekday if day == 0 then modifier = 3 elseif day == 6 then -- 0 = sun 6 = sat modifier = 2 end local experiences = math.random(200,300)*modifier setElementData(killer,"experience", (getElementData(killer,"experience") or 0) + experiences) if getElementData(killer,"humanity") < 0 then setElementData(killer,"bandit",true) end if getElementData(source,"bandit") == true then setElementData(killer,"banditskilled", (getElementData(killer,"banditskilled") or 0) +1) end if headshot == true then setElementData(killer,"headshots", (getElementData(killer,"headshots") or 0) +1) end local xX,yY,zZ = getElementPosition(source) local xk,yk,zk = getElementPosition(killer) local Distancia = getDistanceBetweenPoints3D(xX,yY,zZ,xk,yk,zk) outputChatBox("@Distancia: "..tostring(Distancia)) outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m #FFFFFF || Exp: #32FF32"..experiences,killer,0,128,255,true) outputChatBox("[INFO]#FFFFFF Você foi morto por: #32FF32"..getPlayerName(killer):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m",source,0,128,255,true) --setTimer(function(source,killer)end,6000,1,source) triggerClientEvent("onRollMessageStart",getRootElement(),getPlayerName(source):gsub('#%x%x%x%x%x%x','').." foi morto por "..getPlayerName(killer):gsub('#%x%x%x%x%x%x',''),255,255,255, "died") else triggerClientEvent("onRollMessageStart",getRootElement(),getPlayerName(source):gsub('#%x%x%x%x%x%x','').." morreu.",255,255,255, "died") end If the distance still doesn't return what it should, you can see on chat what the variable returns. Link to comment
AnnaBelle Posted April 15, 2017 Author Share Posted April 15, 2017 I want the 2x message to appear on the weekend, during the week it does not appear Link to comment
Mr.Loki Posted April 15, 2017 Share Posted April 15, 2017 addEventHandler( "onPlayerLogin", root, function ( ) -- check what day it is -- if its weekend outputChatBox( "message that it's 2x???" ) end ) Link to comment
AnnaBelle Posted April 15, 2017 Author Share Posted April 15, 2017 Type when the player kills another appears on the 2x or 3x side Ex:[INFO] You Killed: ^NewYork || Weapon: Sniper || Distance: 200m || Exp: 286 x3 Link to comment
DNL291 Posted April 15, 2017 Share Posted April 15, 2017 (edited) Just use an if statement before outputChatBox, like this: if day == 0 or day == 6 then outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m #FFFFFF || Exp: #32FF32"..experiences,killer,0,128,255,true) outputChatBox("[INFO]#FFFFFF Você foi morto por: #32FF32"..getPlayerName(killer):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m",source,0,128,255,true) end Edited April 15, 2017 by DNL291 Link to comment
Mr.Loki Posted April 15, 2017 Share Posted April 15, 2017 Try this. No need for if statements. local rate = modifier == 2 and "x2" or modifier == 3 and "x3" or "" outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m #FFFFFF || Exp: #32FF32"..experiences/2.." "..modifier,killer,0,128,255,true) Link to comment
DNL291 Posted April 15, 2017 Share Posted April 15, 2017 3 minutes ago, Mr.Loki said: Try this. No need for if statements. local rate = modifier == 2 and "x2" or modifier == 3 and "x3" or "" outputChatBox("[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m #FFFFFF || Exp: #32FF32"..experiences/2.." "..modifier,killer,0,128,255,true) Not sure, but from what I understood, the messages should only be during the weekend. So, outputChatBox should be like this: outputChatBox( "[INFO]#FFFFFF Você matou: #32FF32"..getPlayerName(source):gsub('#%x%x%x%x%x%x','').."#FFFFFF || Arma: #32FF32"..(weapon or "Unknown").."#FFFFFF || Distância: #32FF32"..tostring(math.floor(Distancia)).."m #FFFFFF || Exp: #32FF32"..experiences.." "..(day == 0 and "3x" or "2x"),killer,0,128,255,true) Link to comment
Mr.Loki Posted April 15, 2017 Share Posted April 15, 2017 Just now, AnnaBelle said: Gave error dude at least say what error it gave you... Link to comment
AnnaBelle Posted April 15, 2017 Author Share Posted April 15, 2017 Sorry, it was my mistake now Link to comment
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