PaulDK Posted July 12, 2014 Share Posted July 12, 2014 (edited) my problem is, if the maximum creating object is only 4. how to deduct those in the table. create it again to have a new object then remove the other object that you put first .THANKS in ADVANCE local barrier = {} function consoleCreateObject ( thePlayer, commandName ) local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if ( thePlayer ) then local rx, ry = 0, 0 local rz = getElementRotation ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) table.concat(barrier, 1, 4) table.insert(barrier, createObject ( 3091, x , y, z - 0.5, 0, 0,rz) ) setElementPosition ( thePlayer, x, y, z + 1) end end end end end addCommandHandler ( "barrier", consoleCreateObject ) Edited July 13, 2014 by Guest Link to comment
Et-win Posted July 12, 2014 Share Posted July 12, 2014 I didn't understand ANYTHING you said. Link to comment
xXMADEXx Posted July 12, 2014 Share Posted July 12, 2014 Are you trying to say, you want each player to only be able to create 4 objects? Link to comment
ADCX Posted July 12, 2014 Share Posted July 12, 2014 Server: local barrier = {} function consoleCreateObject(thePlayer,commandName) if (commandName == barrier) then local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if (getPlayerTeam(thePlayer) == SAPD) or (getPlayerTeam(thePlayer) == ArmedForces) or (getPlayerTeam(thePlayer) == SWAT) then local x,y,z = getElementPosition(thePlayer) local _,_,rz = getElementRotation(thePlayer) local Object = createObject(3091,x,y,z - 0.5,0,0,rz) setElementPosition(thePlayer,x,y,z + 1) local PBar = barrier[thePlayer] if not (PBar) then barrier[thePlayer] = {} PBar = {} end if not (PBar[1]) then PBar[1] = Object elseif not (PBar[2]) then PBar[2] = Object elseif not (PBar[3]) then PBar[3] = Object elseif not (PBar[4]) then PBar[4] = Object else destroyElement(PBar[1]) PBar[1] = PBar[2] PBar[2] = PBar[3] PBar[3] = PBar[4] PBar[4] = Object end barrier[thePlayer] = PBar end end end end end addCommandHandler("barrier", consoleCreateObject) function fncPlayerQuit() local PBar = barrier[source] barrier[source] = nil if (PBar[1]) then destroyElement(PBar[1]) end if (PBar[2]) then destroyElement(PBar[2]) end if (PBar[3]) then destroyElement(PBar[3]) end if (PBar[4]) then destroyElement(PBar[4]) end end addEventHandler("onPlayerQuit",getRootElement(),fncPlayerQuit) Your English is poor, but I understood what you meant (barely). Add this to your server-side. Also I formatted your code to be more understandable and fixed some other stuff. Link to comment
PaulDK Posted July 13, 2014 Author Share Posted July 13, 2014 Server: local barrier = {} function consoleCreateObject(thePlayer,commandName) if (commandName == barrier) then local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if (getPlayerTeam(thePlayer) == SAPD) or (getPlayerTeam(thePlayer) == ArmedForces) or (getPlayerTeam(thePlayer) == SWAT) then local x,y,z = getElementPosition(thePlayer) local _,_,rz = getElementRotation(thePlayer) local Object = createObject(3091,x,y,z - 0.5,0,0,rz) setElementPosition(thePlayer,x,y,z + 1) local PBar = barrier[thePlayer] if not (PBar) then barrier[thePlayer] = {} PBar = {} end if not (PBar[1]) then PBar[1] = Object elseif not (PBar[2]) then PBar[2] = Object elseif not (PBar[3]) then PBar[3] = Object elseif not (PBar[4]) then PBar[4] = Object else destroyElement(PBar[1]) PBar[1] = PBar[2] PBar[2] = PBar[3] PBar[3] = PBar[4] PBar[4] = Object end barrier[thePlayer] = PBar end end end end end addCommandHandler("barrier", consoleCreateObject) function fncPlayerQuit() local PBar = barrier[source] barrier[source] = nil if (PBar[1]) then destroyElement(PBar[1]) end if (PBar[2]) then destroyElement(PBar[2]) end if (PBar[3]) then destroyElement(PBar[3]) end if (PBar[4]) then destroyElement(PBar[4]) end end addEventHandler("onPlayerQuit",getRootElement(),fncPlayerQuit) Your English is poor, but I understood what you meant (barely). Add this to your server-side. Also I formatted your code to be more understandable and fixed some other stuff. Thanks For Helping me im sorry for my English Wrong Translate After this Topic i will go Read English Dictionary to Learn more. Thanks a lot brother ... i will test it Link to comment
PaulDK Posted July 13, 2014 Author Share Posted July 13, 2014 Server: local barrier = {} function consoleCreateObject(thePlayer,commandName) if (commandName == barrier) then local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if (getPlayerTeam(thePlayer) == SAPD) or (getPlayerTeam(thePlayer) == ArmedForces) or (getPlayerTeam(thePlayer) == SWAT) then local x,y,z = getElementPosition(thePlayer) local _,_,rz = getElementRotation(thePlayer) local Object = createObject(3091,x,y,z - 0.5,0,0,rz) setElementPosition(thePlayer,x,y,z + 1) local PBar = barrier[thePlayer] if not (PBar) then barrier[thePlayer] = {} PBar = {} end if not (PBar[1]) then PBar[1] = Object elseif not (PBar[2]) then PBar[2] = Object elseif not (PBar[3]) then PBar[3] = Object elseif not (PBar[4]) then PBar[4] = Object else destroyElement(PBar[1]) PBar[1] = PBar[2] PBar[2] = PBar[3] PBar[3] = PBar[4] PBar[4] = Object end barrier[thePlayer] = PBar end end end end end addCommandHandler("barrier", consoleCreateObject) function fncPlayerQuit() local PBar = barrier[source] barrier[source] = nil if (PBar[1]) then destroyElement(PBar[1]) end if (PBar[2]) then destroyElement(PBar[2]) end if (PBar[3]) then destroyElement(PBar[3]) end if (PBar[4]) then destroyElement(PBar[4]) end end addEventHandler("onPlayerQuit",getRootElement(),fncPlayerQuit) Your English is poor, but I understood what you meant (barely). Add this to your server-side. Also I formatted your code to be more understandable and fixed some other stuff. not functioning i set my team to swat but the object not created Link to comment
PaulDK Posted July 13, 2014 Author Share Posted July 13, 2014 Are you trying to say, you want each player to only be able to create 4 objects? Yes, and also if you are in maximum create object you will delete the first barrier to create another barrier. Link to comment
ADCX Posted July 13, 2014 Share Posted July 13, 2014 local barrier = {} function consoleCreateObject(thePlayer,commandName) if (commandName == "barrier") then local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if (getPlayerTeam(thePlayer) == SAPD) or (getPlayerTeam(thePlayer) == ArmedForces) or (getPlayerTeam(thePlayer) == SWAT) then local x,y,z = getElementPosition(thePlayer) local _,_,rz = getElementRotation(thePlayer) local Object = createObject(3091,x,y,z - 0.5,0,0,rz) setElementPosition(thePlayer,x,y,z + 1) local PBar = barrier[thePlayer] if not (PBar) then barrier[thePlayer] = {} PBar = {} end if not (PBar[1]) then PBar[1] = Object elseif not (PBar[2]) then PBar[2] = Object elseif not (PBar[3]) then PBar[3] = Object elseif not (PBar[4]) then PBar[4] = Object else destroyElement(PBar[1]) PBar[1] = PBar[2] PBar[2] = PBar[3] PBar[3] = PBar[4] PBar[4] = Object end barrier[thePlayer] = PBar end end end end end addCommandHandler("barrier", consoleCreateObject) function fncPlayerQuit() local PBar = barrier[source] barrier[source] = nil if (PBar[1]) then destroyElement(PBar[1]) end if (PBar[2]) then destroyElement(PBar[2]) end if (PBar[3]) then destroyElement(PBar[3]) end if (PBar[4]) then destroyElement(PBar[4]) end end addEventHandler("onPlayerQuit",getRootElement(),fncPlayerQuit) I forgot to put 'barrier' in double quotes. It should work now. Link to comment
PaulDK Posted July 14, 2014 Author Share Posted July 14, 2014 local barrier = {} function consoleCreateObject(thePlayer,commandName) if (commandName == "barrier") then local SAPD = getTeamFromName("SAPD") if (SAPD) then local ArmedForces = getTeamFromName("Armed Forces") if (ArmedForces) then local SWAT = getTeamFromName("SWAT") if (SWAT) then if (getPlayerTeam(thePlayer) == SAPD) or (getPlayerTeam(thePlayer) == ArmedForces) or (getPlayerTeam(thePlayer) == SWAT) then local x,y,z = getElementPosition(thePlayer) local _,_,rz = getElementRotation(thePlayer) local Object = createObject(3091,x,y,z - 0.5,0,0,rz) setElementPosition(thePlayer,x,y,z + 1) local PBar = barrier[thePlayer] if not (PBar) then barrier[thePlayer] = {} PBar = {} end if not (PBar[1]) then PBar[1] = Object elseif not (PBar[2]) then PBar[2] = Object elseif not (PBar[3]) then PBar[3] = Object elseif not (PBar[4]) then PBar[4] = Object else destroyElement(PBar[1]) PBar[1] = PBar[2] PBar[2] = PBar[3] PBar[3] = PBar[4] PBar[4] = Object end barrier[thePlayer] = PBar end end end end end addCommandHandler("barrier", consoleCreateObject) function fncPlayerQuit() local PBar = barrier[source] barrier[source] = nil if (PBar[1]) then destroyElement(PBar[1]) end if (PBar[2]) then destroyElement(PBar[2]) end if (PBar[3]) then destroyElement(PBar[3]) end if (PBar[4]) then destroyElement(PBar[4]) end end addEventHandler("onPlayerQuit",getRootElement(),fncPlayerQuit) I forgot to put 'barrier' in double quotes. It should work now. no debugscript. but creating object not functions and SetElementPosition ... HELP PLEASE Link to comment
ADCX Posted July 14, 2014 Share Posted July 14, 2014 Keep in mind, that to this script to work all 3 teams must exist, and player must be in one of them. If I were you I'd change that. 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