Jump to content

[HELP-ME] Patent / level


AnnaBelle

Recommended Posts

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
  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

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

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 by AnnaBelle
Link to comment
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 by NeXuS™
Link to comment
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

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 by DNL291
Link to comment

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

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

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 by DNL291
Link to comment

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

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