Aruna Posted August 19, 2015 Share Posted August 19, 2015 Hola me podrían ayudar a realizar lo siguiente, con el siguiente Scripts un Administrador puede Advertir a un usuario, pero yo quiero que las Advertencia queden acumuladas osea guardadas, es decir que Si yo Advierto a "X" usuario el usuario tenga 1/3 y en la siguiente advertencia se le sume 2/3 y asi sucesivamente. function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function warnPlayer_CMD(thePlayer, theCMD, theTarget, ...) local accN = getAccountName ( getPlayerAccount (thePlayer) ) local groupName = "Admin" or "Moderator" or "SuperModerator" or "Console" -- you can add more if groupName then if theTarget ~= nil and isObjectInACLGroup ("user."..accN,aclGetGroup (groupName) ) -- missing bracket then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("#ff0000[ADVERTENCIA]: "..getPlayerName(thePlayer).."#FFFFFF advertio a "..getPlayerName(theTargetElement).."", getRootElement(), 255, 0, 0, true) outputChatBox("#ff0000[ADVERTENCIA]: #ffffffRazon: #FFFFFF("..tostring(theReason)..")", getRootElement(), 255, 0, 0, true) else outputChatBox("#ff0000[ADVERTENCIA]: #ffffffInvalid target! Syntax: /warn [player] [reason]", thePlayer, 255, 0, 0, true) end end end end addCommandHandler("warn", warnPlayer_CMD, false) Link to comment
aka Blue Posted August 19, 2015 Share Posted August 19, 2015 ¿Y esa función de coger el nombre? :v Usa getPlayerName Link to comment
Aruna Posted August 19, 2015 Author Share Posted August 19, 2015 ¿Y esa función de coger el nombre? :vUsa getPlayerName Pero funciona bien el script Link to comment
MTA Team 0xCiBeR Posted August 19, 2015 MTA Team Share Posted August 19, 2015 Algo así sería, luego puedes usar un condicional (if) y si tiene warnC == 3 realizar un kick, etc. function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function warnPlayer_CMD(thePlayer, theCMD, theTarget, ...) local accN = getAccountName ( getPlayerAccount (thePlayer) ) local groupName = "Admin" or "Moderator" or "SuperModerator" or "Console" -- you can add more if groupName then if theTarget ~= nil and isObjectInACLGroup ("user."..accN,aclGetGroup (groupName) ) -- missing bracket then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local data = getElementData(theTargetElement,"warnC")or 0 local theReason = table.concat(allArgs, " ") setElementData(theTargetElement,"warnC", data + 1) outputChatBox("#ff0000[ADVERTENCIA]: "..getPlayerName(thePlayer).."#FFFFFF advertio a "..getPlayerName(theTargetElement).." ("..tostring(data).."/3)", getRootElement(), 255, 0, 0, true) outputChatBox("#ff0000[ADVERTENCIA]: #ffffffRazon: #FFFFFF("..tostring(theReason)..")", getRootElement(), 255, 0, 0, true) else outputChatBox("#ff0000[ADVERTENCIA]: #ffffffInvalid target! Syntax: /warn [player] [reason]", thePlayer, 255, 0, 0, true) end end end end addCommandHandler("warn", warnPlayer_CMD, false) Link to comment
aka Blue Posted August 19, 2015 Share Posted August 19, 2015 No si puede funcionar fenomenal pero podrías ahorrarte unas líneas. Link to comment
Tomas Posted August 19, 2015 Share Posted August 19, 2015 No si puede funcionar fenomenal pero podrías ahorrarte unas líneas. Esa función busca el jugador por una parte de su nombre, es más fácil. Link to comment
Aruna Posted August 19, 2015 Author Share Posted August 19, 2015 Algo así sería, luego puedes usar un condicional (if) y si tiene warnC == 3 realizar un kick, etc. function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function warnPlayer_CMD(thePlayer, theCMD, theTarget, ...) local accN = getAccountName ( getPlayerAccount (thePlayer) ) local groupName = "Admin" or "Moderator" or "SuperModerator" or "Console" -- you can add more if groupName then if theTarget ~= nil and isObjectInACLGroup ("user."..accN,aclGetGroup (groupName) ) -- missing bracket then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local data = getElementData(theTargetElement,"warnC")or 0 local theReason = table.concat(allArgs, " ") setElementData(theTargetElement,"warnC", data + 1) outputChatBox("#ff0000[ADVERTENCIA]: "..getPlayerName(thePlayer).."#FFFFFF advertio a "..getPlayerName(theTargetElement).." ("..tostring(data).."/3)", getRootElement(), 255, 0, 0, true) outputChatBox("#ff0000[ADVERTENCIA]: #ffffffRazon: #FFFFFF("..tostring(theReason)..")", getRootElement(), 255, 0, 0, true) else outputChatBox("#ff0000[ADVERTENCIA]: #ffffffInvalid target! Syntax: /warn [player] [reason]", thePlayer, 255, 0, 0, true) end end end end addCommandHandler("warn", warnPlayer_CMD, false) Gracias Link to comment
Castillo Posted August 19, 2015 Share Posted August 19, 2015 ¿Y esa función de coger el nombre? :vUsa getPlayerName getPlayerName obtiene el nombre de un jugador, la funcion suya obtiene un jugador por parte de un nombre. Ejemplo: getPlayerFromNamePart ( "Casti" ) > Devuelve al jugador que tenga 'Casti' en su nombre. Sin ofender, pero deberia abstenerse de postear cosas si no sabe siquiera que hacen. Link to comment
aka Blue Posted August 19, 2015 Share Posted August 19, 2015 Ah bueno, nada, fallo mío pues. Link to comment
Recommended Posts