Grievous Posted July 14, 2009 Share Posted July 14, 2009 Hi, I finally got the player blips working on my server. However when I'm in the server some of the player blips stay on the map and radar after the player has disconnected. They don't allways stay and when I reconnect they are gone. 1st thing regarding blips in my script is right after the teams creation. function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end Then I have a money drop. Followed by function playerWasted ( ammo, attacker, weapon, bodypart ) local px,py,pz = getElementPosition(source) createMoney(px,py,pz,100) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerWasted", root, playerWasted ) end function playerQuit () destroyBlipsAttachedTo ( source ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function ADM ( source, weapon, ammo) local taccount = getClientAccount ( source ) if isAdminAccount(taccount) then setPlayerTeam ( source, teamadm ) local x,y,z x = 1127.0999755859 y = -2036.9000244141 z = 69.699996948242 spawnPlayer ( source, x,y,z ) fadeCamera(source, true) takeAllWeapons ( source ) giveWeapon ( source, 5, 1 ) giveWeapon ( source, 24, 500 ) giveWeapon ( source, 32, 1000 ) giveWeapon ( source, 31, 1000 ) setPlayerSkin ( source, 285 ) setPlayerArmor ( source, 100 ) setPlayerMoney ( source, 500 ) setElementHealth ( source, 100 ) blip = createBlipAttachedTo ( source, 0, 2, 255, 0, 0 ) setPlayerNametagColor ( source, 255, 0, 0 ) else outputChatBox ( "You must be logged in as admin", source, 255,0,0 ) triggerClientEvent("onTeamadmin", getRootElement(),source) end end addEvent("onTeamADM", true) addEventHandler("onTeamADM", getRootElement(), ADM) function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end addEventHandler ( "onPlayerQuit", root, playerQuit ) I didn't get any errors with debuging that involved the blips. Any help would be appreciated. I'm not a programer, I'm just learning. I have looked at the broph and playerblips resources and tried changing arguments but nothing I have done worked. Thank you. Link to comment
The_Ex Posted July 14, 2009 Share Posted July 14, 2009 There is problem with destroying blips attached to already disconnected players... But you can call this function onPlayerQuit. It will loop through all the elements attached to player Element and destroy them. function blipDestroy(thePlayer) local blip = getAttachedElements ( thePlayer ) if ( blip ) then for ElementKey, ElementValue in ipairs ( blip ) do destroyElement ( ElementValue ) end end end EDIT: Well, you can also check for blips inside the function with getElementType but that's your choise. Link to comment
Grievous Posted July 15, 2009 Author Share Posted July 15, 2009 The player blips still stay when players leave. New player that join don't see the blips from players that left before they arrived. There is also 1 blip at the farm near los santos that even stays after pc reboot. Am I doing this in function destroyBlipsAttachedTo? you can also check for blips inside the function with getElementType I added the function blipDestroy. So now I have this after team creation and before the money drop. function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end Then after the money drop I have function blipDestroy(thePlayer) local blip = getAttachedElements ( thePlayer ) if ( blip ) then for ElementKey, ElementValue in ipairs ( blip ) do destroyElement ( ElementValue ) end end end end function playerQuit () destroyBlipsAttachedTo ( source ) blipDestroy ( source ) end function playerWasted ( ammo, attacker, weapon, bodypart ) local px,py,pz = getElementPosition(source) createMoney(px,py,pz,100) destroyBlipsAttachedTo ( source ) blipDestroy ( source )--should this be player? end addEventHandler ( "onPlayerWasted", root, playerWasted ) Then I spawn my teams and have this at the bottom function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end addEventHandler ( "onPlayerQuit", root, playerQuit ) function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end Please help me some more. Link to comment
Grievous Posted July 16, 2009 Author Share Posted July 16, 2009 problem solved it was in the playerwasted. Thanks 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