'~DaLesTe^' Posted April 3, 2015 Share Posted April 3, 2015 Hello, I am new to the forum, and I see a script in some servers that it is possible to invite a player to a duel / x1, and works as follows: / duel ID (id of the player). I have a script that adds a number ID for each player: The script works as follows: / duel ID / duel accept / duel decline [You already invited the player] [ duel in progress] When the duel starts appear in chat "The player ..getPlayerName .. (ID:" .. (getPlayerID (source) or "???") .. ") was challenged by ..getPlayerName .. (ID:". . (getPlayerID (source) or "???") .. ") 2 Duel Players get weapons 26, 24, 28 and 31 The place where the two players are moved to the duel / x1 are in size "1" and to accept the second event will go to a map of the location that is to choose the script manually added the cords function getPlayerFromID(id) return call(getResourceFromName("game_id"), "getPlayerFromID", tonumber(id)) end function getPlayerID(player) return getElementData(player,"id") end Who can help me contact me on skype: giovane.martins6 Link to comment
Dimos7 Posted April 3, 2015 Share Posted April 3, 2015 (edited) function Duel(player, id) if id then target = getPlayerFromID(id) if target == false or target == nil then outputChatBox("That id has not connected", player, 255, 0, 0) end outputChatBox("You already invited the player", player, 255, 0, 0) end end addCommandHandler("duel", Duel) function Accept(player) if Duel() then ouputChatBox("The player"..getPlayerName(player).."("..getPlayerID(player)..")".."was challenged by"...getPlayerName(source).."("..getPlayerID(source)..")", root, 83, 138, 165) giveWeapon(source, 26, 250) giveWeapon(source, 24, 250) giveWeapon(source, 28, 250) giveWeapon(source, 31, 250) setElementInterior(source, x,y,z) setElementInterior(player, x,y,z) end else outputChatBox("Duel in progress", player, 255, 0, 0) end addCommandHandler("duel accept", Accept) function Decline(player) Duel() outputChatBox("The player has decline the invite", player, 83, 138, 165) end addCommandHalder("duel decline", Decline) Edited April 3, 2015 by Guest Link to comment
Dimos7 Posted April 3, 2015 Share Posted April 3, 2015 ofc the x,y,z put the map place put the first player and sencond player Link to comment
WhoAmI Posted April 3, 2015 Share Posted April 3, 2015 Well, I'm not sure Dimos7 if it work. I also made my version of it. Didn't test. 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 ); Link to comment
Anubhav Posted April 3, 2015 Share Posted April 3, 2015 Actually WhoAmI's script should work but not Dimos7's, he has used addCommandHandler( "duel accept" ) which is totally wrong and other typo. Link to comment
'~DaLesTe^' Posted April 3, 2015 Author Share Posted April 3, 2015 I needed the code if it works on GNU / Linux, it did not work on my Linux server but rather on Windows. How do I run it on GNU / Linux? Link to comment
WhoAmI Posted April 3, 2015 Share Posted April 3, 2015 It doesn't matter on which OS you will run it. Any errors in /debugscript 3? Link to comment
'~DaLesTe^' Posted April 3, 2015 Author Share Posted April 3, 2015 WARNING: Script 'Duel-System/s.lua:1: is not encoded in UTF-8. Loading as ANSI.. ERROR: Loading script failed: Duel-System/s.lua unexpected symbol near '?' Link to comment
'~DaLesTe^' Posted April 3, 2015 Author Share Posted April 3, 2015 WARNING: Script 'Duel-System/s.lua:1: is not encoded in UTF-8. Loading as ANSI..ERROR: Loading script failed: Duel-System/s.lua unexpected symbol near '?' When I invite the player to duel says: Unable to find player with this ID! More the inserted ID is actually the player's ID Link to comment
'~DaLesTe^' Posted April 3, 2015 Author Share Posted April 3, 2015 WARNING: Script 'Duel-System/s.lua:1: is not encoded in UTF-8. Loading as ANSI..ERROR: Loading script failed: Duel-System/s.lua unexpected symbol near '?' When I invite the player to duel says: Unable to find player with this ID! More the inserted ID is actually the player's ID I believe that this lack to execute the command / duel ID local p = getPlayerFromID( id ); local p = getElementData(getPlayerFromID( id )) 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