golanu21 Posted August 22, 2013 Share Posted August 22, 2013 local warn = {} function command (sourcePlayer, command, who) if not who then outputChatBox ( "Syntaxa Invalida:/warn NUMEJUCATOR." ) return end name = getPlayerFromName(who) if name then local acc = getPlayerAccount ( sourcePlayer ) local accName = getAccountName ( getPlayerAccount ( sourcePlayer ) ) -- get his account name if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if not warn[ name ] then -- hasn't got a warning yet warn[ name ] = 1 else warn[ name ] = warn[ name ] + 1 --alredy has waring(s), so give one more carne = setAccountData(acc, "warns", warn[ name ]) outputChatBox("Administratorul " ..accName.." la avertizat pe : "..who..", si acum are "..warn[name].." avertisment(e)", getRootElement(), 255, 0, 0) end if carne then outputChatBox("asdadad") end if warn[name] >= 3 then -- 3 warnings = ban banPlayer(name, true, who, false, sourcePlayer, "Avertismente.", 0 ) outputChatBox("Jucatorul "..who.." a fost banat permanent din cauza avertisementelor.", getRootElement(), 255, 0, 0) end end end end addCommandHandler("warn", command) addEventHandler("onPlayerLogin", getRootElement(), function (_, acc) if (acc) then carr = getAccountData(acc, "warns") end if carr then warn[ name ] = warn[ name ] outputChatBox("gfgfg") end end) the text asdadad is there... the account information is saved... but on Player Login ,, the text gfgfg is there but when i wse the command /warn..is start for the first number. 0 Link to comment
csiguusz Posted August 22, 2013 Share Posted August 22, 2013 carne = setAccountData(acc, "warns", warn[ name ]) You are setting the warns of the player who executed the command, not whose who get warned. And for the loign: addEventHandler("onPlayerLogin", getRootElement(), function (_, acc) if (acc) then carr = getAccountData(acc, "warns") end if carr then warn[ source ] = tonumber ( carr ) outputChatBox("gfgfg") end end) Link to comment
Castillo Posted August 22, 2013 Share Posted August 22, 2013 local warn = { } function command ( sourcePlayer, command, who ) if ( not who ) then outputChatBox ( "Syntaxa Invalida:/warn NUMEJUCATOR.", sourcePlayer ) return end local name = getPlayerFromName ( who ) if ( name ) then local acc = getPlayerAccount ( sourcePlayer ) local accName = getAccountName ( getPlayerAccount ( sourcePlayer ) ) -- get his account name if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then if ( not warn[ name ] ) then -- hasn't got a warning yet warn [ name ] = 1 else warn [ name ] = ( warn [ name ] + 1 ) --alredy has waring(s), so give one more carne = setAccountData ( acc, "warns", warn [ name ] ) outputChatBox ( "Administratorul ".. accName .." la avertizat pe : ".. who ..", si acum are ".. warn [ name ] .." avertisment(e)", getRootElement(), 255, 0, 0 ) end if ( carne ) then outputChatBox ( "asdadad" ) end if ( warn [ name ] >= 3 ) then -- 3 warnings = ban banPlayer ( name, true, who, false, sourcePlayer, "Avertismente.", 0 ) outputChatBox ( "Jucatorul ".. who .." a fost banat permanent din cauza avertisementelor.", getRootElement(), 255, 0, 0 ) end end end end addCommandHandler ( "warn", command ) addEventHandler ( "onPlayerLogin", getRootElement(), function ( _, acc ) local warns = tonumber ( getAccountData ( acc, "warns" ) ) or 0 warn [ name ] = warns end ) Link to comment
golanu21 Posted August 23, 2013 Author Share Posted August 23, 2013 server.lua:36: table index is nil Link to comment
TAPL Posted August 23, 2013 Share Posted August 23, 2013 Change: warn [ name ] = warns to warn [ source ] = warns Link to comment
Castillo Posted August 23, 2013 Share Posted August 23, 2013 Yes, my bad, I didn't notice that. Link to comment
golanu21 Posted August 23, 2013 Author Share Posted August 23, 2013 np , thanx for help 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