Jump to content

[Question] How can i add this to server side?


Tokio

Recommended Posts

i have this code in client side:

function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) 
    if element and getElementType( element ) == "object" and button == "left" and state == "down" and getElementModel(element) == 1829 then 
		triggerServerEvent ("eszakirablas", root, getLocalPlayer()) 
    end 
end 
addEventHandler("onClientClick", getRootElement(), onMachineClick) 

but i want add this to server side, is it possible?

Link to comment
7 minutes ago, Mr.Loki said:

this why not working?

function tesztteszt( theButton, theState, thePlayer, absoluteX, absoluteY, worldX, worldY, worldZ, element )
if element and getElementType( element ) == "object" and theButton == "left" and theState == "down" and getElementModel(element) == 1829 then
    if ( idozito [ thePlayer ] ~= nil ) then
      outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true );
    else
      setElementFrozen(thePlayer, true)
      setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false)
      setTimer(setElementFrozen,10000,1,thePlayer,false)
      setTimer(setPedAnimation,10000,1,thePlayer)
      randomM = math.random(500000,1500000)
      setTimer(function()
          givePlayerMoney(thePlayer,randomM)
      end,10000,1)
      setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true)
      setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatod a széfet! #01AC41(/eszaki)",thePlayer,255,255,255,true)
      setTimer(Boltrablas,900000,1)
      idozito [ thePlayer ] = setTimer ( function ( thePlayer )
          idozito [ thePlayer ] = nil;
        end, 900000, 1, thePlayer);
    end
end
end
addEventHandler( "onElementClicked", getRootElement(), tesztteszt )

 

Link to comment
22 minutes ago, Mr.Loki said:

Invalid function parameters check the wiki for them.

function erablas( button, state, thePlayer )
    if button == "left" and state == "down" then
        if getElementType( source ) == "object" then
            local x, y, z = getElementPosition( thePlayer )
            local x1, y1, z1 = getElementPosition( source ) 
            local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 )
        if distance < 4 then
			if ( idozito [ thePlayer ] ~= nil ) then
			outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true );
			else
			setElementFrozen(thePlayer, true)
			setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false)
			setTimer(setElementFrozen,10000,1,thePlayer,false)
			setTimer(setPedAnimation,10000,1,thePlayer)
			randomM = math.random(500000,1500000)
			setTimer(function()
			givePlayerMoney(thePlayer,randomM)
			end,10000,1)
			setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true)
			setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true)
			setTimer(Boltrablas,900000,1)
			idozito [ thePlayer ] = setTimer ( function ( thePlayer )
			idozito [ thePlayer ] = nil;
			end, 900000, 1, thePlayer);
		end
	else
		outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true );
	end
end
end
end
addEventHandler( "onElementClicked", getRootElement( ), erablas )

Now working, but i have a problem.. Why can i rob the thing, when other player robbed?

Link to comment
24 minutes ago, Mr.Loki said:

You can use set and getElementData to make a simple check to see if it's being robbed or insert the element into your idozito table then check to see if it is in the table.

			setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true)

when the thing can rob again, flood this text :S how to fix this?

Link to comment
1 minute ago, Mr.Loki said:

show me the code you have now

function erablas( button, state, thePlayer )
    if button == "left" and state == "down" then
        if getElementType( source ) == "object" and getElementModel(source) == 1829 then
            local x, y, z = getElementPosition( thePlayer )
            local x1, y1, z1 = getElementPosition( source ) 
            local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 )
        if distance < 4 then
			if ( idozito [ thePlayer ] ~= nil ) then
			outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true );
			else
			setElementFrozen(thePlayer, true)
			setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false)
			setTimer(setElementFrozen,10000,1,thePlayer,false)
			setTimer(setPedAnimation,10000,1,thePlayer)
			randomM = math.random(500000,1500000)
			setTimer(function()
			givePlayerMoney(thePlayer,randomM)
			destroyElement(safe)
			end,10000,1)
			setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true)
			setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true)
			setTimer(Boltrablas,900000,1)
			idozito [ thePlayer ] = setTimer ( function ( thePlayer )
			idozito [ thePlayer ] = nil;
			end, 900000, 1, thePlayer);
		end
	else
		outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true );
	end
end
end
end
addEventHandler( "onElementClicked", getRootElement( ), erablas )

 

Link to comment

Try this

function erablas( button, state, thePlayer )
	if button == "left" and state == "down" then
		if getElementType( source ) == "object" and getElementModel(source) == 1829 then
			local x, y, z = getElementPosition( thePlayer )
			local x1, y1, z1 = getElementPosition( source ) 
			local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 )
			if distance < 4 then
				if ( idozito [ source ] ~= nil ) then
					outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true );
				else
					setElementFrozen(thePlayer, true)
					setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false)
					setTimer(setElementFrozen,10000,1,thePlayer,false)
					setTimer(setPedAnimation,10000,1,thePlayer)
					randomM = math.random(500000,1500000)
				setTimer(function()
					givePlayerMoney(thePlayer,randomM)
					destroyElement(safe)
				end,10000,1)
				setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true)
				setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true)
				setTimer(Boltrablas,900000,1)
				idozito [ source ] = setTimer ( function ( )
				idozito [ source ] = nil;
				end, 900000, 1, source);
			end
		else
			outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true );
		end
	end
end
end
addEventHandler( "onElementClicked", getRootElement( ), erablas )

 

  • Thanks 1
Link to comment
32 minutes ago, Mr.Loki said:

Try this


function erablas( button, state, thePlayer )
	if button == "left" and state == "down" then
		if getElementType( source ) == "object" and getElementModel(source) == 1829 then
			local x, y, z = getElementPosition( thePlayer )
			local x1, y1, z1 = getElementPosition( source ) 
			local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 )
			if distance < 4 then
				if ( idozito [ source ] ~= nil ) then
					outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true );
				else
					setElementFrozen(thePlayer, true)
					setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false)
					setTimer(setElementFrozen,10000,1,thePlayer,false)
					setTimer(setPedAnimation,10000,1,thePlayer)
					randomM = math.random(500000,1500000)
				setTimer(function()
					givePlayerMoney(thePlayer,randomM)
					destroyElement(safe)
				end,10000,1)
				setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true)
				setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true)
				setTimer(Boltrablas,900000,1)
				idozito [ source ] = setTimer ( function ( )
				idozito [ source ] = nil;
				end, 900000, 1, source);
			end
		else
			outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true );
		end
	end
end
end
addEventHandler( "onElementClicked", getRootElement( ), erablas )

 

Working fine, thanks! :D

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