MouNiR.Dz Posted June 14, 2022 Share Posted June 14, 2022 Hi , i want to make a function excute when the player wanted level change my objective is to make when the player gets 2 stars wanted level , his nametag color become red If you want to suggest on me to use a Timer checks if the player has wanted level , i know this but i want another way to avoid timers as possible and there is no OnPlayerWantedLevelChange soo that's the problem Link to comment
roaddog Posted June 15, 2022 Share Posted June 15, 2022 Well if you have your own system to give player wanted level, you can do it easily put triggerEvent like such. function yourOwnGivePlayerWantedLevel(player, wl) local lastWl = getPlayerWantedLevel(player) if wl then local newWl = wl + lastWl -- Can be minus can be plus setPlayerWantedLevel(player, newWl) triggerEvent("onPlayerWantedLevelChange", player, lastWl, newWl) end end Link to comment
MouNiR.Dz Posted June 15, 2022 Author Share Posted June 15, 2022 8 hours ago, NeverGiveup said: Well if you have your own system to give player wanted level, you can do it easily put triggerEvent like such. function yourOwnGivePlayerWantedLevel(player, wl) local lastWl = getPlayerWantedLevel(player) if wl then local newWl = wl + lastWl -- Can be minus can be plus setPlayerWantedLevel(player, newWl) triggerEvent("onPlayerWantedLevelChange", player, lastWl, newWl) end end I Like your idea but can you help me in creating the event function my object is to create a blip attached to the player that has wanted levels and to remove the blip when the player wanted level are clear I want a help because i don't work with blips too much That's my idea right now: function checkCriminals() local cr,cg,cb = getPlayerNametagColor(source) if getPlayerWantedLevel(source) >= 1 and cr,cg,cb ~= 255,0,0 then setPlayerNametagColor(source,255,0,0) for index, element in ipairs ( getAttachedElements ( source ) ) do if ( getElementType ( element ) ~= "blip" ) then createBlipAttachedTo(source,0,25,255,0,0) end if not element then createBlipAttachedTo(source,0,25,255,0,0) end end end end addEvent("onPlayerWantedLevelChange",true) addEventHandler("onPlayerWantedLevelChange",root,checkCriminals) Link to comment
roaddog Posted June 15, 2022 Share Posted June 15, 2022 (edited) local criminals = {} function checkCriminals() local cr, cg, cb = getPlayerNametagColor(source) if getPlayerWantedLevel(source) >= 1 and cr, cg, cb ~= 255, 0, 0 then setPlayerNametagColor(source, 255, 0, 0) criminals[source] = createBlipAttachedTo(source,0, 25, 255, 0, 0) else setPlayerNametagColor(source, 0, 255, 0) if criminals[source] and isElement(criminals[source]) then destroyElement(criminals[source]) criminals[source] = nil end end end addEvent("onPlayerWantedLevelChange", true) addEventHandler("onPlayerWantedLevelChange", root, checkCriminals) untested i guess it works.. Edited June 15, 2022 by NeverGiveup Link to comment
MouNiR.Dz Posted June 16, 2022 Author Share Posted June 16, 2022 20 hours ago, NeverGiveup said: local criminals = {} function checkCriminals() local cr, cg, cb = getPlayerNametagColor(source) if getPlayerWantedLevel(source) >= 1 and cr, cg, cb ~= 255, 0, 0 then setPlayerNametagColor(source, 255, 0, 0) criminals[source] = createBlipAttachedTo(source,0, 25, 255, 0, 0) else setPlayerNametagColor(source, 0, 255, 0) if criminals[source] and isElement(criminals[source]) then destroyElement(criminals[source]) criminals[source] = nil end end end addEvent("onPlayerWantedLevelChange", true) addEventHandler("onPlayerWantedLevelChange", root, checkCriminals) untested i guess it works.. I didn't test urs but i used the same "If" like you previously and i got a error reported in Debug on "cr, cg, cb ~= 255, 0, 0" i think it should be "(cr ~= 255 and cg ~= 0 and cb ~= 0 ) then" Anyways thanks for your help and i think i can continue now , Soo Thanks again<3 1 Link to comment
MouNiR.Dz Posted June 17, 2022 Author Share Posted June 17, 2022 (edited) Hi again , i want a help in this if cr, cg, cb ~= 255, 0, 0 then so thats didn't work but that works without any errors in debug if ( cr ~= 255 and cg ~= 0 and cb ~= 0 ) then but what i want is to check if the player nametag is red or no but it's not happening sometimes if the player is yellow sometimes so i want help in checking if the player nametag is red or no EDIT: I found a solution so i used this local cr, cg, cb = getPlayerNametagColor(args[1]) local crcgcb = tostring(cr)..tostring(cg)..tostring(cb) if ( crcgcb ~= "25500" ) then i know it's pretty weird but that what i have found But of course if there is another solution tell me Edited June 17, 2022 by MouNiR.Dz Link to comment
Moderators IIYAMA Posted June 17, 2022 Moderators Share Posted June 17, 2022 12 minutes ago, MouNiR.Dz said: so i want help in checking if the player nametag is red or no This is red: (cr == 255 and cg == 0 and cb == 0) -- red This is not red: not (cr == 255 and cg == 0 and cb == 0) -- not red if not (cr == 255 and cg == 0 and cb == 0) then end Link to comment
MouNiR.Dz Posted June 17, 2022 Author Share Posted June 17, 2022 Nice to meet you IIYAMA Thank you so much for your help and yes it wasn't a difficult solution but somehow i didn't think or try it Thanks again 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