Storm-Hanma Posted November 3, 2017 Share Posted November 3, 2017 Hello all I seen some freeroam servers have duel system ,so I think to make one for my server there is not errors but even script not work function getPlayerFromID ( id ) return call ( getResourceFromName ( "game_id" ), "getPlayerFromID", tonumber ( id ) ); end function getPlayerID ( player ) return getElementData ( player, "id" ); end duelTable = { }; fightPlace = { x, y, z, interior, dimension }; function tpToFightPlace ( element ) setElementPosition ( element, fightPlace[1], fightPlace[2], fightPlace[3] ); setElementInterior ( element, fightPlace[4] ); setElementDimension ( element, fightPlace[5] ); giveWeapon ( element, 26 ); giveWeapon ( element, 24 ); giveWeapon ( element, 28 ); giveWeapon ( element, 31 ); end function duel ( player, cmd, arg ) if ( tonumber ( arg ) ) then local p = getPlayerFromID ( id ); if ( isElement ( p ) ) then if ( not duelTable [ p ] ) then duelTable [ p ] = player; outputChatBox ( "You sent invite to " .. getPlayerName ( p ) .. "!", player, 255, 255, 255, true ) else outputChatBox ( "This player is already challanged!", player, 255, 0, 0, true ); end else outputChatBox ( "Unable to find player with this ID!", player, 255, 0, 0, true ); end end if ( arg == "accept" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then outputChatBox ( "The player " .. getPlayerName ( player ) .. " (ID:" .. getPlayerID ( player ) .. ") was challanged by " .. getPlayerName ( p ) .. " (ID:" .. getPlayerID ( p ) .. ")", root, 255, 255, 255, true ); tpToFightPlace ( p ); tpToFightPlace ( player ); duelTable [ player ] = nil; else outputChatBox ( "Noone challanged you!", player, 255, 0, 0, true ); end elseif ( arg == "decline" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then duelTable [ player ] = nil; outputChatBox ( getPlayerName ( player ) .. " declined.", p, 255, 0, 0, true ); end else return; end end addCommandHandler ( "duel", duel ); Nor errors I added this code in server side but not working Link to comment
dex. Posted November 4, 2017 Share Posted November 4, 2017 function getPlayerFromID ( id ) return call ( getResourceFromName ( "game_id" ), "getPlayerFromID", tonumber ( id ) ); end function getPlayerID ( player ) return getElementData ( player, "id" ); end duelTable = { }; fightPlace = { x, y, z, interior, dimension }; function tpToFightPlace ( element ) setElementPosition ( element, fightPlace[1], fightPlace[2], fightPlace[3] ); setElementInterior ( element, fightPlace[4] ); setElementDimension ( element, fightPlace[5] ); giveWeapon ( element, 26 ); giveWeapon ( element, 24 ); giveWeapon ( element, 28 ); giveWeapon ( element, 31 ); end function duel ( player, cmd, arg ) if ( tonumber ( arg ) ) then local p = getPlayerFromID ( id ); if ( isElement ( p ) ) then if ( not duelTable [ p ] ) then duelTable [ p ] = player; outputChatBox ( "You sent invite to " .. getPlayerName ( p ) .. "!", player, 255, 255, 255, true ) else outputChatBox ( "This player is already challanged!", player, 255, 0, 0, true ); end else outputChatBox ( "Unable to find player with this ID!", player, 255, 0, 0, true ); end end if ( arg == "accept" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then outputChatBox ( "The player " .. getPlayerName ( player ) .. " (ID:" .. getPlayerID ( player ) .. ") was challanged by " .. getPlayerName ( p ) .. " (ID:" .. getPlayerID ( p ) .. ")", root, 255, 255, 255, true ); tpToFightPlace ( p ); tpToFightPlace ( player ); duelTable [ player ] = nil; else outputChatBox ( "Noone challanged you!", player, 255, 0, 0, true ); end elseif ( arg == "decline" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then duelTable [ player ] = nil; outputChatBox ( getPlayerName ( player ) .. " declined.", p, 255, 0, 0, true ); end else return; end end addCommandHandler ( "duel", duel ) not tesed Link to comment
Storm-Hanma Posted November 4, 2017 Author Share Posted November 4, 2017 41 minutes ago, dex. said: function getPlayerFromID ( id ) return call ( getResourceFromName ( "game_id" ), "getPlayerFromID", tonumber ( id ) ); end function getPlayerID ( player ) return getElementData ( player, "id" ); end duelTable = { }; fightPlace = { x, y, z, interior, dimension }; function tpToFightPlace ( element ) setElementPosition ( element, fightPlace[1], fightPlace[2], fightPlace[3] ); setElementInterior ( element, fightPlace[4] ); setElementDimension ( element, fightPlace[5] ); giveWeapon ( element, 26 ); giveWeapon ( element, 24 ); giveWeapon ( element, 28 ); giveWeapon ( element, 31 ); end function duel ( player, cmd, arg ) if ( tonumber ( arg ) ) then local p = getPlayerFromID ( id ); if ( isElement ( p ) ) then if ( not duelTable [ p ] ) then duelTable [ p ] = player; outputChatBox ( "You sent invite to " .. getPlayerName ( p ) .. "!", player, 255, 255, 255, true ) else outputChatBox ( "This player is already challanged!", player, 255, 0, 0, true ); end else outputChatBox ( "Unable to find player with this ID!", player, 255, 0, 0, true ); end end if ( arg == "accept" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then outputChatBox ( "The player " .. getPlayerName ( player ) .. " (ID:" .. getPlayerID ( player ) .. ") was challanged by " .. getPlayerName ( p ) .. " (ID:" .. getPlayerID ( p ) .. ")", root, 255, 255, 255, true ); tpToFightPlace ( p ); tpToFightPlace ( player ); duelTable [ player ] = nil; else outputChatBox ( "Noone challanged you!", player, 255, 0, 0, true ); end elseif ( arg == "decline" ) then local p = duelTable [ player ]; if ( isElement ( p ) ) then duelTable [ player ] = nil; outputChatBox ( getPlayerName ( player ) .. " declined.", p, 255, 0, 0, true ); end else return; end end addCommandHandler ( "duel", duel ) not tesed its base on id ,i need /duel playername not id Link to comment
Storm-Hanma Posted November 4, 2017 Author Share Posted November 4, 2017 no one to help? my baddd 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