Jump to content

help xml


Derpy

Recommended Posts

hello im try to make this but it no work

local RootNode = xmlCreateFile("new.xml"," punishlist") 
local xmlPunishNickBranch = xmlCreateChild ( RootNode, "punished_players_nick" ) 
local xmlPunishSerialBranch = xmlCreateChild ( RootNode, "punished_players_serial" ) 
local xmlPunishTimeBranch = xmlCreateChild ( RootNode, "punished_players_time" ) 
local punishedPlayer = getPlayerName(target) 
local punishedPlayerSerial = getPlayerSerial(target) 
local punishedPlayerSerialSource = getPlayerSerial(source) 
function punishPlayer(thePlayer,commandName,target,time,reason) 
  if not RootNode then 
     xmlCreateFile("new.xml"," punishlist") 
     xmlCreateChild ( RootNode, "punished_players_nick" ) 
     xmlCreateChild ( RootNode, "punished_players_serial" ) 
     xmlCreateChild ( RootNode, "punished_players_time" ) 
end 
if RootNode then 
     if not isPlayerMuted(target) then 
           if time then 
                    if reason then 
                           setPlayerMuted(target,true) 
                           xmlNodeSetValue(xmlPunishNickBranch,punishedPlayer) 
                           xmlNodeSetValue(xmlPunishSerialBranch,punishedPlayerSerial) 
                           xmlNodeSetValue(xmlPunishTimeBranch,time) 
                           xmlSaveFile(RootNode) 
                           outputChatBox(punishedPlayer.." has been muted by: "..source.." for: "..time.." ("..reason..")") 
                           outputServerLog(punishedPlayer.." has been muted by: "..source.." for: "..time.." ("..reason..")") 
                              else if not time then 
                                  outputChatBox("time not set",source) 
                                    else if not reason then 
                                          outputChatBox("reason not set",source) 
                                    end 
                              end 
                        end 
                  end 
            end 
      end 
end 
addCommandHandler("punish",punishPlayer) 
  
function onPunishedJoin() 
if RootNode then 
if punishedPlayerSerialSource == xmlNodeGetValue(xmlPunishSerialBranch) then 
if xmlNodeGetValue(xmlPunishTimeBranch) >= 0 then 
setPlayerMuted(source,true) 
end 
end 
end 
end 
addEventHandler("onPlayerJoin",root,onPunishedJoin) 

line 5 bad argument getPlayerName expected element at argument 1, got string *nickname*

line 6 bad argument getPlayerSerial expected player at argument 1, got string *nickname*

line 14 bad argument isPlayerMuted

i am try to punish player for time in seconds i put and if time pass he get unmutted

but if he reconnect he not evade mute and mute set back time and if time expired then player unmuted

please help me bad at xml

Link to comment
  
function punishPlayer(thePlayer,commandName,target,time,reason) 
local RootNode = xmlCreateFile("new.xml"," punishlist") 
local xmlPunishNickBranch = xmlCreateChild ( RootNode, "punished_players_nick" ) 
local xmlPunishSerialBranch = xmlCreateChild ( RootNode, "punished_players_serial" ) 
local xmlPunishTimeBranch = xmlCreateChild ( RootNode, "punished_players_time" ) 
local punishedPlayer = getPlayerFromName(target) 
local punishedPlayerSerial = getPlayerSerial(target) -- line 8 
local punishedPlayerSerialSource = getPlayerSerial(source) -- 9 
  if not RootNode then 
     xmlCreateFile("new.xml"," punishlist") 
     xmlCreateChild ( RootNode, "punished_players_nick" ) 
     xmlCreateChild ( RootNode, "punished_players_serial" ) 
     xmlCreateChild ( RootNode, "punished_players_time" ) 
end 
if RootNode then 
     if not isPlayerMuted(target) then 
           if time then 
                    if reason then 
                           setPlayerMuted(target,true) 
                           xmlNodeSetValue(xmlPunishNickBranch,punishedPlayer) 
                           xmlNodeSetValue(xmlPunishSerialBranch,punishedPlayerSerial) 
                           xmlNodeSetValue(xmlPunishTimeBranch,time) 
                           xmlSaveFile(RootNode) 
                           outputChatBox(punishedPlayer.." has been muted by: "..source.." for: "..time.." ("..reason..")") 
                           outputServerLog(punishedPlayer.." has been muted by: "..source.." for: "..time.." ("..reason..")") 
                              else if not time then 
                                  outputChatBox("time not set",source) 
                                    else if not reason then 
                                          outputChatBox("reason not set",source) 
                                    end 
                              end 
                        end 
                  end 
            end 
      end 
end 
addCommandHandler("punish",punishPlayer) 
  
function onPunishedJoin() 
if RootNode then 
if punishedPlayerSerialSource == xmlNodeGetValue(xmlPunishSerialBranch) then 
if xmlNodeGetValue(xmlPunishTimeBranch) >= 0 then 
setPlayerMuted(source,true) 
end 
end 
end 
end 
addEventHandler("onPlayerJoin",root,onPunishedJoin) 

me no understand

line 8 expected element got string *playernick*

me not know how to put element so it work

line 9 expected element got nil

onplayerjoin source is player who entering servers and element so how error here?

helpp

Link to comment

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...