knightscript Posted January 23, 2016 Share Posted January 23, 2016 Hello, im mapping a duel arena, but i have a problem, i don´t know how to make the script for it, what i want to do, is that when a player wants to make a duel with another player, he writes down for example /duel playername, and that if the other player writes down /acceptduel they will both be warped to my map, where they will be in separate cages, i know how to warp the players to a place (SetElementPosition, source, x, y, z), and i want to create a timer which will remove the gate, but i know how to do that too, but what i dont know how to script is the /duel part, is there any tutorial on how to do this? Link to comment
ViRuZGamiing Posted January 24, 2016 Share Posted January 24, 2016 function sendDuelInvite (player, opponent) addCommandHandler("acceptduel", function(source) if (source == opponent) then outputChatBox(getPlayerName(source).." accepted your duel!", player, 255, 165, 0) -- Duel stuff here end end end addCommandHandler("duel", function(source, cmd, arg) if (arg) then local player = getPlayerFromName(arg) if (player) then outputChatBox(getPlayerName(source).." has send you a duel invite! Write /acceptduel to accept it!", player, 255, 165, 0) sendDuelInvite(source, player) end end end) I think this would work (Server sided) Link to comment
knightscript Posted January 24, 2016 Author Share Posted January 24, 2016 Hello, thanks for the code snippet, well I have my duel system right here: function quitarrejas() destroyElement(reja1) destroyElement(reja2) end function InvitacionDuelo (player, opponent) addCommandHandler("aceptarduelo", function(source) if (source == opponent) then setElementData(source,"enduelo","1") setElementData(player,"enduelo","1") outputChatBox(getPlayerName(source).." ha aceptado tu duelo!", player, 255, 165, 0) outputChatBox("Has aceptado el duelo de "..getPlayerName(player).."!.", source, 255, 165, 0) local antiheadshotsource = getElementData(source,"antiheadshot") local antiheadshotplayer = getElementData(player,"antiheadshot") x,y,z = getElementPosition(source) x1,y1,z1 = getElementPosition(player) sourceaccount = getAccount(getPlayerName(source)) playeraccount = getAccount(getPlayerName(player)) if antiheadshotsource == "1" then setElementData(source,"temporalantiheadshot","1") setElementData(source,"antiheadshot","0") outputChatBox("Tu casco ha sido desactivado durante el duelo!.",source) end if antiheadshotplayer == "1" then setElementData(player,"temporalantiheadshot","1") setElementData(player,"antiheadshot","0") outputChatBox("Tu casco ha sido desactivado durante el duelo!.",player) end reja1 = createObject(971, 2440.8, 2448, 72, 0, 0, 42) reja2 = createObject(971, 2394.5, 2493.8999, 72, 0, 0, 42) setElementPosition(source,2392.86, 2495.01, 69.47) setElementPosition(player,2442.01, 2446.62, 69.47) takeAllWeapons(source) takeAllWeapons(player) giveWeapon ( source, weaponid, 999 ) giveWeapon ( player, weaponid, 999 ) setTimer(quitarrejas, 4000, 1) triggerClientEvent ( source, "Countdown", source) triggerClientEvent ( player, "Countdown", player) end end) end addCommandHandler("duelo", function(source, cmd, arg, weapon) if (arg) then local player = getPlayerFromName(arg) local checarsienduelo1 = getElementData(source,"enduelo") local checarsienduelo2 = getElementData(player,"enduelo") local antiheadshotsource = getElementData(source,"antiheadshot") local antiheadshotplayer = getElementData(player,"antiheadshot") if checarsienduelo1 == "1" then outputChatBox("Tu ya estas en un duelo!",source) cancelEvent() end if checarsienduelo2 == "1" then outputChatBox("Ese jugador ya esta en un duelo!",source) cancelEvent() end weaponid = getWeaponIDFromName (weapon) if (player) then if checarsienduelo1 == "0" and checarsienduelo2 == "0" then outputChatBox(getPlayerName(source).." Te ha enviado una invitación de duelo con "..weapon.." ("..weaponid.."). /aceptarduelo para iniciarlo!", player, 255, 165, 0) outputChatBox("Has enviado la solicitud de duelo a "..getPlayerName(player).." con el arma "..weapon.." ("..weaponid.."). Espera a que acepte tu duelo!", source, 255, 165, 0) InvitacionDuelo(source, player) end end end end) function CuandoMuere(totalAmmo, killer, killerWeapon, bodypart, stealth) setElementData(source,"enduelo","0") setElementData(killer,"enduelo","0") local sourceacc = getAccount(getPlayerName(source)) local killeracc = getAccount(getPlayerName(killer)) local checarcascosource = getElementData(source,"temporalantiheadshot") local checarcascokiller = getElementData(killer,"temporalantiheadshot") if checarcascosource == "1" then setElementData(source,"antiheadshot","1") outputChatBox("Tu casco se te ha regresado!",source) end if checarcascokiller == "1" then setElementData(killer,"antiheadshot","1") outputChatBox("Tu casco se te ha regresado!",killer) end if sourceacc == sourceaccount then setElementPosition(source, x, y, z) end if killeracc == playeraccount then setElementPosition(killer, x1, y1, z1) end if sourceacc == playeraccount then setElementPosition(source, x, y, z) end if killeracc == sourceaccount then setElementPosition(killer, x1, y1, z1) end local resource = getResourceFromName("duelos") restartResource(resource) end addEventHandler ("onPlayerWasted", getRootElement(), CuandoMuere) the problem is, each time a duel is finished, i have to restart the resource because the gate doesnt disappear, do you know what is the problem? Link to comment
Storm-Hanma Posted November 2, 2017 Share Posted November 2, 2017 Why u giving them a map with gate? When they accept duel make sure they bet money to ,let them decide were to fight Link to comment
Moderators IIYAMA Posted November 2, 2017 Moderators Share Posted November 2, 2017 This code is far from ready for multiplayer. Lots of bugs. One of your main problems is the addCommandHandler function, please do some research about it. It will bug your whole system if you do not understand correctly how it works. https://wiki.multitheftauto.com/wiki/AddCommandHandler Is this what you mean with gate? (it is recommended to write English code for situations like this) local reja1 = createObject(971, 2440.8, 2448, 72, 0, 0, 42) local reja2 = createObject(971, 2394.5, 2493.8999, 72, 0, 0, 42) setTimer(quitarrejas, 4000, 1, reja1, reja2) function quitarrejas(reja1, reja2) if isElement(reja1) then destroyElement(reja1) end if isElement(reja2) then destroyElement(reja2) end end 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