SoMoRay Posted April 18, 2013 Posted April 18, 2013 hi I want createBlip for Teams what wrong I want him show in map ---------------- blip Thwar addEventHandler("onResourceStart", resourceRoot, function () local x,y,z = getElementPosition ( myPlayer ) if ( getPlayerTeam ( player ) ) and ( getPlayerTeam ( player ) == getTeamFromName ( "Thwar" ) ) then myBlip = createBlip ( x, y, z, 0, 2, 255, 0, 0,255) createBlipAttachedTo( myBlip , 0 , 2, 255, 0 , 0 , 255 ) end end ) ------------------- blip Police addEventHandler("onResourceStart", resourceRoot, function () local x,y,z = getElementPosition ( myPlayer ) if ( getPlayerTeam ( player ) ) and ( getPlayerTeam ( player ) == getTeamFromName ( "Police" ) ) then myBlip = createBlip ( x, y, z, 0, 2, 0, 0, 255, 255) createBlipAttachedTo( myBlip , 0 , 2, 0, 0 , 255 , 255 ) end end ) ------------- BLIP WAFAQ addEventHandler("onResourceStart", resourceRoot, function () local x,y,z = getElementPosition ( myPlayer ) if ( getPlayerTeam ( player ) ) and ( getPlayerTeam ( player ) == getTeamFromName ( "Wafaq" ) ) then myBlip = createBlip ( x, y, z, 0, 2, 0, 255, 0, 255) createBlipAttachedTo( myBlip , 0 , 2, 0, 255 , 0 , 255 ) end end )
OGF Posted April 18, 2013 Posted April 18, 2013 You don't have player or myPlayer defined anywhere as far as this script shows, also you don't need 3 event handlers that are executing similar things that is what elseif statements are for. you don't use createBlip and createBlipAttachedTo. Just use createBlipAttachedTo edit: you know what you got to many fked up things. TRY THIS CODE..not tested. function checkTeams() players = getElementsByType ( "player" ) for k, player in ipairs ( players ) do if ( getPlayerTeam ( player ) ) then if getTeamName ( getPlayerTeam( player ) ) == "Thwar" then createBlipAttachedTo( player, 0, 2, 255, 0, 0, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Police" then createBlipAttachedTo( player, 0, 2, 0, 0, 255, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Wafaq" then createBlipAttachedTo( player, 0, 2, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, checkTeams )
SoMoRay Posted April 18, 2013 Author Posted April 18, 2013 You don't have player or myPlayer defined anywhere as far as this script shows, also you don't need 3 event handlers that are executing similar things that is what elseif statements are for.you don't use createBlip and createBlipAttachedTo. Just use createBlipAttachedTo edit: you know what you got to many fked up things. TRY THIS CODE..not tested. function checkTeams() players = getElementsByType ( "player" ) for k, player in ipairs ( players ) do if ( getPlayerTeam ( player ) ) then if getTeamName ( getPlayerTeam( player ) ) == "Thwar" then createBlipAttachedTo( player, 0, 2, 255, 0, 0, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Police" then createBlipAttachedTo( player, 0, 2, 0, 0, 255, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Wafaq" then createBlipAttachedTo( player, 0, 2, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, checkTeams ) doesn't work so can anyone help me what wrong's is there in this code it's take all team blip green and I want it Police Blue and Thwar Red and Wafaq Green local Team1 = 'Thwar' local Team2 = 'Wafaq' local Team3 = 'Police' function blips ( ) for i,v in ipairs ( getElementsByType ( 'player' ) ) do local team = getPlayerTeam ( v ); if team then if getTeamName ( Thwar) == Team1 then createBlipAttachedTo ( 0,2,255,0,0,255); elseif getTeamName ( Wafaq ) == Team2 then createBlipAttachedTo ( 0,2,0,255,0,255); elseif getTeamName ( Police ) == Team3 then createBlipAttachedTo ( 0,2,0,0,255,255); end end end end addEventHandler ( 'onResourceStart', resourceRoot, blips ); function destroyBlip ( ) local attached = getAttachedElements ( source ) for _,i in ipairs ( attached ) do if getElementType ( i ) == 'blip' then destroyElement ( i ) end end end addEventHandler ( 'onPlayerQuit', root, destroyBlip )
OGF Posted April 18, 2013 Posted April 18, 2013 I Just tested the code that I gave you and it does work. what the heck can you possibly do to make it mess up? I don't understand what you are trying to do now..I can't understand you. and your code makes no damn sense, where is thwar , wafaq , police defined? Use my code. function checkTeams() players = getElementsByType ( "player" ) for k, player in ipairs ( players ) do if ( getPlayerTeam ( player ) ) then if getTeamName ( getPlayerTeam( player ) ) == "Thwar" then createBlipAttachedTo( player, 0, 2, 255, 0, 0, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Police" then createBlipAttachedTo( player, 0, 2, 0, 0, 255, 255 ) elseif getTeamName ( getPlayerTeam ( player ) ) == "Wafaq" then createBlipAttachedTo( player, 0, 2, 0, 255, 0, 255 ) end end end end addEventHandler ( "onResourceStart", resourceRoot, checkTeams )
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