Derpy Posted August 1, 2014 Share Posted August 1, 2014 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
RottenFlesh Posted August 3, 2014 Share Posted August 3, 2014 You have defined the "target" variable until line 8, and as it is local it will only work inside the scope of that function. You have to declare the "target" variable outside the function or move everything inside the function. Link to comment
Addlibs Posted August 3, 2014 Share Posted August 3, 2014 Line 5: local punishedPlayer = getPlayerName(target) Don't you mean getPlayerFromName(target) ? You're trying to insert a string value in the place of a element argument... Link to comment
Derpy Posted August 3, 2014 Author Share Posted August 3, 2014 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
Addlibs Posted August 4, 2014 Share Posted August 4, 2014 getPlayerSerial ( punishedPlayer ) 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