acp___(PL) Posted April 4, 2010 Share Posted April 4, 2010 I wrote a script which adds a blip in the color of the player, but I do not know why it added more than once ... local g_Root = getRootElement() local g_ResRoot = getResourceRootElement(getThisResource()) function pomalujSamochodGracza() if getPlayerName(source) == "[2RT]acp___(PL)" then setVehicleColor(getPedOccupiedVehicle(source), 79, 79, 79, 79) local blip = getElementAttachedTo(source) if not blip or ( blip and getElementType(blip) == "blip" and getBlipIcon(blip) ~= 0 and getBlipSize(blip) ~= 4 ) then createBlipAttachedTo(source, 0, 1, 0, 0, 255, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..getPlayerName(source), 3, 255, 0, 0) end elseif getPlayerName(source) == "[2RT]Wojak[PL]" then setVehicleColor(getPedOccupiedVehicle(source), 65, 65, 65, 65) local blip = getElementAttachedTo(source) if not blip or ( blip and getElementType(blip) == "blip" and getBlipIcon(blip) ~= 0 and getBlipSize(blip) ~= 4 ) then createBlipAttachedTo(source, 0, 1, 153, 150, 26, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..getPlayerName(source), 3, 255, 0, 0) end end end addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_Root , pomalujSamochodGracza) Link to comment
Dark Dragon Posted April 4, 2010 Share Posted April 4, 2010 your problem is, that you check if the player element is attached to something, which is not the case at all. the blip is attached to the player, not the other way around. use getAttachedElements in a loop and use your size and icon check there if getPlayerName(source) == "[2RT]acp___(PL)" then setVehicleColor(getPedOccupiedVehicle(source), 79, 79, 79, 79) local elements = getAttachedElements(source) local docreate = true for i,v in ipairs(elements) do if ( getElementType(v) == "blip" and getBlipIcon(v) == 0 and getBlipSize(v) == 4 ) then docreate = false break end end if docreate then createBlipAttachedTo(source, 0, 1, 0, 0, 255, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..getPlayerName(source), 3, 255, 0, 0) end end Link to comment
acp___(PL) Posted April 11, 2010 Author Share Posted April 11, 2010 I misunderstood how this command ... but I want to solve it differently function pomalujSamochodGracza() local blip = blipPlayerListTable[source] local playerName = getPlayerName(source) if playerName == "[2RT]acp___(PL)" then if not blip then blipPlayerListTable[source] = createBlipAttachedTo(source, 0, 1, 0, 0, 255, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..playerName, 3, 255, 0, 0) else attachElements(blipPlayerListTable[source], source) end end end function usunGraczZTabeliBipow() if blipPlayerListTable[source] then destroyElement(blipPlayerListTable[source]) end end addEventHandler('onPlayerQuit', g_Root , usunGraczZTabeliBipow) addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_Root , pomalujSamochodGracza) addEvent('onPlayerPickUpRacePickup') addEventHandler('onPlayerPickUpRacePickup', g_Root , pomalujSamochodGracza) how to remove blips? It just does not work: function usunGraczZTabeliBipow() if blipPlayerListTable[source] then destroyElement(blipPlayerListTable[source]) end end 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