Simple0x47 Posted July 8, 2017 Share Posted July 8, 2017 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
Shayan816 Posted July 8, 2017 Author Share Posted July 8, 2017 I started resource and when i do /pvp_check i spawned in location and when i die or get out of PVP zone.. i cant use /pvp_check again.. i did /pvp_check but nothing happened Link to comment
Simple0x47 Posted July 8, 2017 Share Posted July 8, 2017 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
Shayan816 Posted July 8, 2017 Author Share Posted July 8, 2017 oh sorry, and Thank you so much, Its Working thank you man Link to comment
itHyperoX Posted July 8, 2017 Share Posted July 8, 2017 when u type /pvp use setElementData(player,"weapon-id1,weapon) then takeplayer weapon when out of pvp zone getelementdanta weapon-id1 then giveWeapon removeElementData 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