Giovany Mito Posted July 6, 2019 Share Posted July 6, 2019 I'm trying to make a, function upLevel, call the playsound, using the triggerClientEvent but not giving Server: function upLevel (thePlayer) for i,player in ipairs(getElementsByType("player")) do if ( player ) then if ( getPlayerAccount(player) ) and not ( isGuestAccount(getPlayerAccount(player)) ) then setElementData(player,"minutes",(getElementData(player,"minutes") or 0) +1) if ( getElementData(player,"minutes") > 1 ) then setElementData(player,"minutes",0) setElementData(player,"Level",(getElementData(player,"Level") or 0) +1) local bonus = math.random(25,950) local interest = math.random(25,150) local value = (bonus-interest) givePlayerMoney(player,value) outputChatBox("#FFFFFF[ #FAAC58FW-LEVEL #FFFFFF]", player, 255, 255, 255, true ) outputChatBox("#FAAC58**#FFFFFFVocê ganhou mais um #FAAC58level", player, 255, 255, 255, true ) outputChatBox("#FAAC58**#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true ) triggerClientEvent ( thePlayer, "blipuplevel", thePlayer ) -- CHAMAR AUDIO CLIENT local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then end end end end end end setTimer(upLevel,60000,0) Client : local sx,sy = guiGetScreenSize() local px,py = 1366,768 local x,y = (sx/px),(sy/py) function drawLevel () local levelProgress = (getElementData(localPlayer,"minutes") or 0) dxDrawRectangle(x*803, y*743, x*160/58*levelProgress, y*19, tocolor(0, 0, 0, 130), false) dxDrawRectangle(x*800, y*740, x*170, y*25, tocolor(0, 0, 0, 120), false) dxDrawText("LEVEL: "..(getElementData(localPlayer,"Level") or 0), x*854, y*746, x*10, y*10, tocolor(255, 255, 255, 255), x*0.9, "default", "left", "top", false, false, false, false, false) end addEventHandler("onClientRender",getRootElement(),drawLevel) function blipup () local sound = playSound("som/blip.mp3") setSoundVolume(sound, 0.5) -- set the sound volume to 50% end addEvent( "blipup", true ) addEventHandler("blipuplevel", localPlayer, blipup) ERRO [2019-07-06 11:55:06] WARNING: [FW]Score/Arc_s.Lua:2: Bad argument @ 'triggerClientEvent' [Expected string at argument 1, got nil] Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 10 minutes ago, giovanymito said: I'm trying to make a, function upLevel, call the playsound, using the triggerClientEvent but not giving Server: function upLevel (thePlayer) for i,player in ipairs(getElementsByType("player")) do if ( player ) then if ( getPlayerAccount(player) ) and not ( isGuestAccount(getPlayerAccount(player)) ) then setElementData(player,"minutes",(getElementData(player,"minutes") or 0) +1) if ( getElementData(player,"minutes") > 1 ) then setElementData(player,"minutes",0) setElementData(player,"Level",(getElementData(player,"Level") or 0) +1) local bonus = math.random(25,950) local interest = math.random(25,150) local value = (bonus-interest) givePlayerMoney(player,value) outputChatBox("#FFFFFF[ #FAAC58FW-LEVEL #FFFFFF]", player, 255, 255, 255, true ) outputChatBox("#FAAC58**#FFFFFFVocê ganhou mais um #FAAC58level", player, 255, 255, 255, true ) outputChatBox("#FAAC58**#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true ) triggerClientEvent ( thePlayer, "blipuplevel", thePlayer ) -- CHAMAR AUDIO CLIENT local accName = getAccountName ( getPlayerAccount ( player ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then end end end end end end setTimer(upLevel,60000,0) Client : local sx,sy = guiGetScreenSize() local px,py = 1366,768 local x,y = (sx/px),(sy/py) function drawLevel () local levelProgress = (getElementData(localPlayer,"minutes") or 0) dxDrawRectangle(x*803, y*743, x*160/58*levelProgress, y*19, tocolor(0, 0, 0, 130), false) dxDrawRectangle(x*800, y*740, x*170, y*25, tocolor(0, 0, 0, 120), false) dxDrawText("LEVEL: "..(getElementData(localPlayer,"Level") or 0), x*854, y*746, x*10, y*10, tocolor(255, 255, 255, 255), x*0.9, "default", "left", "top", false, false, false, false, false) end addEventHandler("onClientRender",getRootElement(),drawLevel) function blipup () local sound = playSound("som/blip.mp3") setSoundVolume(sound, 0.5) -- set the sound volume to 50% end addEvent( "blipup", true ) addEventHandler("blipuplevel", localPlayer, blipup) ERRO [2019-07-06 11:55:06] WARNING: [FW]Score/Arc_s.Lua:2: Bad argument @ 'triggerClientEvent' [Expected string at argument 1, got nil] triggerClientEvent(thePlayer, "blipuplevel", thePlayer) thePlayer - where is defined? This player doesn't exist. Link to comment
Felix5k Posted July 6, 2019 Share Posted July 6, 2019 triggerClientEvent(player, "blipuplevel", player) Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 2 minutes ago, Felix5k said: triggerClientEvent(player, "blipuplevel", player) @giovanymito besides, imho it's not good way to send multiple triggers within loop instead of one. Link to comment
Giovany Mito Posted July 6, 2019 Author Share Posted July 6, 2019 I'm a beginner, I do not know much 29 minutes ago, Felix5k said: triggerClientEvent(player, "blipuplevel", player) did not work Link to comment
Kaarpas Posted July 6, 2019 Share Posted July 6, 2019 Você adicionou o evento errado. Linha 18 do client: addEvent("blipuplevel", true) Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 (edited) 19 minutes ago, giovanymito said: I'm a beginner, I do not know much did not work If you want, you can try my version, which also i optimized a bit. -- Server-side function upLevel() local players = getElementsByType("player") local get_players = {} for i = 1, #players do local player = players[i] local player_acc = getPlayerAccount(player) if player and player_acc and not isGuestAccount(player_acc) then local minutes = getElementData(player, "minutes") setElementData(player, minutes, minutes or 0 + 1) if minutes and minutes > 1 then local level = getElementData(player, "Level") local bonus = math.random(25, 950) local interest = math.random(25, 150) local value = bonus - interest setElementData(player, "Level", level or 0 + 1) givePlayerMoney(player, value) outputChatBox("#FFFFFF[ #FAAC58FW-LEVEL #FFFFFF]", player, 255, 255, 255, true) outputChatBox("#FAAC58**#FFFFFFVocê ganhou mais um #FAAC58level", player, 255, 255, 255, true) outputChatBox("#FAAC58**#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true) table.insert(get_players, player) end end end triggerClientEvent(get_players, "blipuplevel", resourceRoot) end setTimer(upLevel, 60000, 0) -- Client-side function blipuplevel() local sound = playSound("som/blip.mp3") setSoundVolume(sound, 0.5) end addEvent("blipuplevel", true) addEventHandler("blipuplevel", resourceRoot, blipuplevel) Edited July 6, 2019 by majqq Missed timer. Link to comment
Giovany Mito Posted July 6, 2019 Author Share Posted July 6, 2019 (edited) 1 hour ago, majqq said: If you want, you can try my version, which also i optimized a bit. -- Server-side function upLevel() local players = getElementsByType("player") local get_players = {} for i = 1, #players do local player = players[i] local player_acc = getPlayerAccount(player) if player and player_acc and not isGuestAccount(player_acc) then local minutes = getElementData(player, "minutes") setElementData(player, minutes, minutes or 0 + 1) if minutes and minutes > 1 then local level = getElementData(player, "Level") local bonus = math.random(25, 950) local interest = math.random(25, 150) local value = bonus - interest setElementData(player, "Level", level or 0 + 1) givePlayerMoney(player, value) outputChatBox("#FFFFFF[ #FAAC58FW-LEVEL #FFFFFF]", player, 255, 255, 255, true) outputChatBox("#FAAC58**#FFFFFFVocê ganhou mais um #FAAC58level", player, 255, 255, 255, true) outputChatBox("#FAAC58**#FFFFFFPagamento : R$ #00FF00"..value, player, 255, 255, 255, true) table.insert(get_players, player) end end end triggerClientEvent(get_players, "blipuplevel", resourceRoot) end setTimer(upLevel, 60000, 0) -- Client-side function blipuplevel() local sound = playSound("som/blip.mp3") setSoundVolume(sound, 0.5) end addEvent("blipuplevel", true) addEventHandler("blipuplevel", resourceRoot, blipuplevel) [2019-07-06 14:09:55] SCRIPT ERROR: [FW]Score/Arc_s.Lua:26: unexpected symbol near '�' [2019-07-06 14:09:55] ERROR: Loading script failed: [FW]Score/Arc_s.Lua:26: unexpected symbol near '�' Edited July 6, 2019 by giovanymito Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 52 minutes ago, giovanymito said: [2019-07-06 14:09:55] SCRIPT ERROR: [FW]Score/Arc_s.Lua:26: unexpected symbol near '�' [2019-07-06 14:09:55] ERROR: Loading script failed: [FW]Score/Arc_s.Lua:26: unexpected symbol near '�' The problem was in outputChatBox, so add them again, i also find out other problem, check again. function upLevel() local players = getElementsByType("player") local get_players = {} for i = 1, #players do local player = players[i] local player_acc = getPlayerAccount(player) if player and player_acc and not isGuestAccount(player_acc) then local minutes = getElementData(player, "minutes") if not minutes then setElementData(player, "minutes", 1) else setElementData(player, "minutes", minutes + 1) end if getElementData(player, "minutes") > 1 then local level = getElementData(player, "Level") or 0 local bonus = math.random(25, 950) local interest = math.random(25, 150) local value = bonus - interest setElementData(player, "minutes", 0) setElementData(player, "Level", level + 1) givePlayerMoney(player, value) table.insert(get_players, player) end end end triggerClientEvent(get_players, "blipuplevel", resourceRoot) end setTimer(upLevel, 60000, 0) Link to comment
Giovany Mito Posted July 6, 2019 Author Share Posted July 6, 2019 [2019-07-06 15:13:26] WARNING: [FW]Score/Arc_s.Lua:26: Bad usage @ 'triggerClientEvent' [<min_mta_version> section in the meta.xml is incorrect or missing (expected at least server 1.3.0-9.04570 because a send list is being used)] Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 3 minutes ago, giovanymito said: [2019-07-06 15:13:26] WARNING: [FW]Score/Arc_s.Lua:26: Bad usage @ 'triggerClientEvent' [<min_mta_version> section in the meta.xml is incorrect or missing (expected at least server 1.3.0-9.04570 because a send list is being used)] Add to meta. <min_mta_version client="1.5.6" server="1.5.6"/> Link to comment
Giovany Mito Posted July 6, 2019 Author Share Posted July 6, 2019 It worked and how do I go through the chatbox now? Link to comment
Scripting Moderators ds1-e Posted July 6, 2019 Scripting Moderators Share Posted July 6, 2019 1 minute ago, giovanymito said: It worked and how do I go through the chatbox now? Like before, but will be better if you will rewrite them once again, and not copy, because of invisible special character, probably. Link to comment
Giovany Mito Posted July 6, 2019 Author Share Posted July 6, 2019 28 minutes ago, majqq said: Like before, but will be better if you will rewrite them once again, and not copy, because of invisible special character, probably. function kikarplayer ( theClient, commandName, kickedName, ... ) if hasObjectPermissionTo ( theClient, "function.kickPlayer" ) then if not ... then return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) end local reason = table.concat({...}," ") local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") local kickedPlayer = getPlayerFromName(kickedName) if not isElement(kickedPlayer) then outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) end outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. " #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true ) banPlayer ( kickedPlayer, theClient, reason ) else outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) end end addCommandHandler ( "kick", kikarplayer ) How do I give permission for a larger group to use this function example: admin, moderator, sub-moderador .... Link to comment
Kaarpas Posted July 6, 2019 Share Posted July 6, 2019 function kikarplayer (theClient, commandName, kickedName, ...) local account = getAccountName (getPlayerAccount (theClient)) if isObjectInACLGroup ("user."..account, aclGetGroup ("Admin")) then if not ... then return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) end local reason = table.concat({...}," ") local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") local kickedPlayer = getPlayerFromName(kickedName) if not isElement(kickedPlayer) then outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) end outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. " #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true ) banPlayer ( kickedPlayer, theClient, reason ) else outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) end end addCommandHandler ( "kick", kikarplayer ) 1 Link to comment
DNL291 Posted July 6, 2019 Share Posted July 6, 2019 1 hour ago, giovanymito said: function kikarplayer ( theClient, commandName, kickedName, ... ) if hasObjectPermissionTo ( theClient, "function.kickPlayer" ) then if not ... then return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) end local reason = table.concat({...}," ") local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") local kickedPlayer = getPlayerFromName(kickedName) if not isElement(kickedPlayer) then outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) end outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. " #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true ) banPlayer ( kickedPlayer, theClient, reason ) else outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) end end addCommandHandler ( "kick", kikarplayer ) You could've created another topic since this isn't related to the original subject. Try this: function kikarplayer ( theClient, commandName, kickedName, ... ) if isPlayerStaff(theClient) then if not kickedName then return outputChatBox ("#bf2e2e* Erro: /kick [nick] [motivo]",theClient,255,255,255,true) end local reason = table.concat({...}," ") local kickerName = getPlayerName(theClient):gsub("#%x%x%x%x%x%x","") local kickedPlayer = getPlayerFromName(kickedName) if not isElement(kickedPlayer) then return outputChatBox ("#bf2e2e* Erro: Player Invalido!",theClient,255,255,255,true) end outputChatBox ( "#c9c9c9[#1a6cefFW-INFORMA#c9c9c9]O #1a6cef" .. kickerName .. " #c9c9c9Kickou o Player #1a6cef" ..getPlayerName(kickedPlayer):gsub("#%x%x%x%x%x%x","").. "#c9c9c9 | Motivo #1a6cef" ..reason.. "#c9c9c9", getRootElement(), 255, 0, 0, true ) banPlayer ( kickedPlayer, theClient, reason ) else outputChatBox ("#bf2e2e* Erro: Você Não tem Permissão!",theClient,255,255,255,true) end end addCommandHandler ( "kick", kikarplayer ) -- https://wiki.multitheftauto.com/wiki/IsPlayerStaff local staffACLs = { aclGetGroup("Admin"), aclGetGroup("Moderator"), aclGetGroup("SuperModerator"), } function isPlayerStaff(p) local acc = getPlayerAccount(p) if not acc then return false end if isGuestAccount(acc) then return false end local object = getAccountName(acc) for _,group in ipairs(staffACLs) do if isObjectInACLGroup("user."..object,group) then return true end end return false end Also, the command/function is supposed to kick the player but it's using 'banPlayer', so change it to kickPlayer. 1 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