Jump to content

Need Help !!


Recommended Posts

Okay I understand your problem let me solve it. I'll be back with code in some minutes.

-- VARIABLES

  local spawns = {
  --x, y, z, rotZ
  { 2096.3, 1286.6, 10.82, 90 },
  { 1928.8, 1469.5, 10.82, 90 },
  { 2032.6,1429.3,10.82, 90 },
  { 2019.8, 1545.5, 10.82, 90 },
  { 2162.1, 1644.7, 11.2, 90 },
  { 2121.3, 1493.9, 10.82, 90 },
  { 2163.7, 1483.6, 24.1, 90 },
  { 2114.1, 1483.8, 24.1, 90 },
  { 1939.8, 1343.2, 9.2, 90 },
  { 2025.5, 1623.7, 11.9, 90 }
  } 

  local pvp_players = {}

-- FUNCTIONS

  function startResource()
      removeCommandHandler( "pvp" ) -- JUST IN CASE
  end

  function startPVP( thePlayer )
	if ( thePlayer ) then
     if not ( pvp_players[ thePlayer ] ) then
       local x, y, z = unpack( spawns[ math.random( 1, #spawns ) ] )
       if ( getElementModel( thePlayer ) ) then
        setElementPosition( thePlayer, x, y, z )
       else
        spawnPlayer( thePlayer, x, y, z, 0, math.random( 0, 275 ), 0, 0 )
       end
       pvp_players[ thePlayer ] = true -- CHANGE TO FALSE pvp_players[ playerObject ] WHEN HE LEAVES THE PVP
      end
    else
     outputChatBox( "You are already playing in PVP", thePlayer, 255, 0, 0 )
    end
  end

-- COMMAND HANDLERS

	addCommandHandler( "pvp_check", startPVP ) -- JUST TO CHECK IF PVP_CHECK WORKS CORRECTLY AND IF IT WORKS CORRECTLY TRY TO CHANGE TO pvp AND CHECK THEN IF IT FAILS BECAUSE MAYBE IT'S DUE TO AN OVERWRITTEN COMMAND

-- EVENT HANDLERS

	addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startResource )

 

Link to comment

Because it doesn't have the handlers, you should add them by yourself... nvm.

-- VARIABLES

  local spawns = {
  --x, y, z, rotZ
  { 2096.3, 1286.6, 10.82, 90 },
  { 1928.8, 1469.5, 10.82, 90 },
  { 2032.6,1429.3,10.82, 90 },
  { 2019.8, 1545.5, 10.82, 90 },
  { 2162.1, 1644.7, 11.2, 90 },
  { 2121.3, 1493.9, 10.82, 90 },
  { 2163.7, 1483.6, 24.1, 90 },
  { 2114.1, 1483.8, 24.1, 90 },
  { 1939.8, 1343.2, 9.2, 90 },
  { 2025.5, 1623.7, 11.9, 90 }
  } 

  local pvp_players = {}

-- FUNCTIONS

  function startResource()
      removeCommandHandler( "pvp" ) -- JUST IN CASE
  end

  function startPVP( thePlayer )
	if ( thePlayer ) then
     if not ( pvp_players[ thePlayer ] ) then
       local x, y, z = unpack( spawns[ math.random( 1, #spawns ) ] )
       if ( getElementModel( thePlayer ) ) then
        setElementPosition( thePlayer, x, y, z )
       else
        spawnPlayer( thePlayer, x, y, z, 0, math.random( 0, 275 ), 0, 0 )
       end
       pvp_players[ thePlayer ] = true -- CHANGE TO FALSE pvp_players[ playerObject ] WHEN HE LEAVES THE PVP
      end
    else
     outputChatBox( "You are already playing in PVP", thePlayer, 255, 0, 0 )
    end
  end

  -- UNINITIALIZE PLAYER FROM PVP

  function uninitPVP()
   if ( source ) then
    pvp_players[ source ] = nil
   end
  end

-- COMMAND HANDLERS

	addCommandHandler( "pvp_check", startPVP ) -- JUST TO CHECK IF PVP_CHECK WORKS CORRECTLY AND IF IT WORKS CORRECTLY TRY TO CHANGE TO pvp AND CHECK THEN IF IT FAILS BECAUSE MAYBE IT'S DUE TO AN OVERWRITTEN COMMAND

-- EVENT HANDLERS

	addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), startResource )

    addEventHandler( "onPlayerWasted", root, uninitPVP ) 
    addEventHandler( "onPlayerQuit", root, uninitPVP )

 

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