Jump to content

[Help]why my Script is not working ?


Perfect

Recommended Posts

Posted

Hi All, I get this script from a topic and i add some changes but script not working.

function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
          if not getElementData(tPlayer, "auto.unban") then 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..targetPlayer.." !", player) 
          else 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protestion from "..targetPlayer.." !", player) 
          end 
     end 
end 
  
addCommandHandler("banprotect", autounban) 
  
function(player,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if getElementData(player, "auto.unban") then 
 local tIP = getPlayerIP(targetPlayer) 
 local tSerial = getPlayerSerial(targetPlayer) 
 local tName = getPlayerName(targetPlayer) 
 addEventHandler ( "onBan", root, 
    function ( theBan ) 
        local bSerial = getBanSerial ( theBan ) 
        local bIP = getBanIP ( theBan ) 
        local bNick = getBanNick ( theBan ) 
        if ( tSerial [ bSerial ] or tIP [ bIP ] or tName [ bNick ] ) then 
            removeBan ( theBan ) 
        end 
    end 
) 

Posted

debug it.

something like this

  
function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
outputChatBox ( "tplayer = true" ) 
          if not getElementData(tPlayer, "auto.unban") then 
outputChatBox ( "auto ban data = false" ) 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..targetPlayer.." !", player) 
          else 
outputChatBox ( "auto ban data = true" ) 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protestion from "..targetPlayer.." !", player) 
          end 
     end 
end 
  

Posted
debug it.

something like this

  
function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
outputChatBox ( "tplayer = true" ) 
          if not getElementData(tPlayer, "auto.unban") then 
outputChatBox ( "auto ban data = false" ) 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..targetPlayer.." !", player) 
          else 
outputChatBox ( "auto ban data = true" ) 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protestion from "..targetPlayer.." !", player) 
          end 
     end 
end 
  

i put that and i got

warning unban/unban.lua:1: unexpected symbol near "("

Posted
i put that and i got

warning unban/unban.lua:1: unexpected symbol near "("

Read all the posts: viewtopic.php?f=91&t=46871#p466107

Thnx, script started working and added some changes then again script stoped working

  
function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
outputChatBox ( " "..targetPlayer.." = True", player, 0, 255, 0) 
          else 
outputChatBox ( " "..targetPlayer.." = False", player, 255, 0, 0) 
          if not getElementData(tPlayer, "auto.unban") then 
outputChatBox ( "Banned = false", player, 0, 255, 0) 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..targetPlayer.." !", player, 0, 255, 0) 
          else 
outputChatBox ( "#FF0000Banned = true", player, 255, 255, 255, true) 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protection from "..targetPlayer.." !", player, 255, 0, 0) 
          end 
     end 
end 
  
addCommandHandler("banprotect", autounban) 
  
function unban(player,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if getElementData(player, "auto.unban") then 
 local tIP = getPlayerIP(targetPlayer) 
 local tSerial = getPlayerSerial(targetPlayer) 
 local tName = getPlayerName(targetPlayer) 
 addEventHandler ( "onBan", root, 
    function ( theBan ) 
        local bSerial = getBanSerial ( theBan ) 
        local bIP = getBanIP ( theBan ) 
        local bNick = getBanNick ( theBan ) 
        if ( tSerial [ bSerial ] or tIP [ bIP ] or tName [ bNick ] ) then 
            removeBan ( theBan ) 
               end 
            end    
) 
     end  
end 
  

Posted

U debugged it wrong

  
function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
outputChatBox ( " "..tPlayer.." = True", player, 0, 255, 0) 
-- targetPlayer Returns nothing, bcs it is needed getplayerfromname. 
          else 
outputChatBox ( "Target player = False", player, 255, 0, 0) 
  
-- because it returns nil we used this 
  
          if not getElementData(tPlayer, "auto.unban") then 
outputChatBox ( "Banned = false", player, 0, 255, 0) 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..tPlayer.." !", player, 0, 255, 0) 
          else 
outputChatBox ( "#FF0000Banned = true", player, 255, 255, 255, true) 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protection from "..tPlayer.." !", player, 255, 0, 0) 
          end 
     end 
end 
  
addCommandHandler("banprotect", autounban) 
  
function unban(player,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if getElementData(player, "auto.unban") then 
 local tIP = getPlayerIP(targetPlayer) 
 local tSerial = getPlayerSerial(targetPlayer) 
 local tName = getPlayerName(targetPlayer) 
 addEventHandler ( "onBan", root, 
    function ( theBan ) 
        local bSerial = getBanSerial ( theBan ) 
        local bIP = getBanIP ( theBan ) 
        local bNick = getBanNick ( theBan ) 
        if ( tSerial [ bSerial ] or tIP [ bIP ] or tName [ bNick ] ) then 
            removeBan ( theBan ) 
               end 
            end   
) 
     end 
end 
  
  
  
  

Posted
U debugged it wrong
  
function autounban(player,cmd,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if tPlayer then 
outputChatBox ( " "..tPlayer.." = True", player, 0, 255, 0) 
-- targetPlayer Returns nothing, bcs it is needed getplayerfromname. 
          else 
outputChatBox ( "Target player = False", player, 255, 0, 0) 
  
-- because it returns nil we used this 
  
          if not getElementData(tPlayer, "auto.unban") then 
outputChatBox ( "Banned = false", player, 0, 255, 0) 
               setElementData(tPlayer, "auto.unban", true) 
               outputChatBox("You have given unbanned protection to "..tPlayer.." !", player, 0, 255, 0) 
          else 
outputChatBox ( "#FF0000Banned = true", player, 255, 255, 255, true) 
               setElementData(tPlayer, "lift.permission", false) 
               outputChatBox("You have taken unbanned protection from "..tPlayer.." !", player, 255, 0, 0) 
          end 
     end 
end 
  
addCommandHandler("banprotect", autounban) 
  
function unban(player,targetPlayer) 
     tPlayer = getPlayerFromName(targetPlayer) 
     if getElementData(player, "auto.unban") then 
 local tIP = getPlayerIP(targetPlayer) 
 local tSerial = getPlayerSerial(targetPlayer) 
 local tName = getPlayerName(targetPlayer) 
 addEventHandler ( "onBan", root, 
    function ( theBan ) 
        local bSerial = getBanSerial ( theBan ) 
        local bIP = getBanIP ( theBan ) 
        local bNick = getBanNick ( theBan ) 
        if ( tSerial [ bSerial ] or tIP [ bIP ] or tName [ bNick ] ) then 
            removeBan ( theBan ) 
               end 
            end   
) 
     end 
end 
  
  
  
  

working but in wrong way. if i typed /banprotect then its shows "target player = false" and "banned false".

and anothere thing is i typed /banprotect but it did'nt show anything.

i want if i type /banprotect not player name then it will show something like this "Please write player name. /banprotect

Help!!!

Posted
  
function autounban(player,cmd,targetPlayer) 
     local tPlayer = getPlayerFromName(targetPlayer) 
    if getElementData(tPlayer, "auto.unban") == false then 
    setElementData(tPlayer, 'auto.unban', true) 
    outputDebugString('data added') 
    else 
        setElementData(tPlayer, 'auto.unban', false) 
    outputDebugString('data removed') 
        end 
end 
addCommandHandler("pban", autounban) 

Posted
  
function autounban(player,cmd,targetPlayer) 
     local tPlayer = getPlayerFromName(targetPlayer) 
    if getElementData(tPlayer, "auto.unban") == false then 
    setElementData(tPlayer, 'auto.unban', true) 
    outputDebugString('data added') 
    else 
        setElementData(tPlayer, 'auto.unban', false) 
    outputDebugString('data removed') 
        end 
end 
addCommandHandler("pban", autounban) 

This will fix this

working but in wrong way. if i typed /banprotect then its shows "target player = false" and "banned false".

and anothere thing is i typed /banprotect but it did'nt show anything.

i want if i type /banprotect not player name then it will show something like this "Please write player name. /banprotect

Posted

The element data are stored on live elements, so if they are destroyed, meaning if the player leaves the server then the element data get's destroyed.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...