Resmurf Posted June 11, 2011 Share Posted June 11, 2011 i wanna make blips for the team color root = getRootElement () color = { 0, 255, 0 } players = {} resourceRoot = getResourceRootElement ( getThisResource () ) function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end function onPlayerQuit () destroyBlipsAttachedTo ( source ) end function onPlayerWasted ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end function setBlipsColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then color = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } for id, player in ipairs( getElementsByType ( "player" ) ) do destroyBlipsAttachedTo ( player ) if ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end end function setBlipColor ( source, commandName, r, g, b ) if ( tonumber ( b ) ) then destroyBlipsAttachedTo ( source ) players[source] = { tonumber ( r ), tonumber ( g ), tonumber ( b ) } createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) end end addCommandHandler ( "setblipscolor", setBlipsColor ) addCommandHandler ( "setblipcolor", setBlipColor ) addEventHandler ( "onResourceStart", resourceRoot, onResourceStart ) addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerWasted", root, onPlayerWasted ) 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 where should i put this code local r,g,b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(player)) Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 you want to make the players blip color as his team color if one exists right? You can put this function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if getPlayerTeam1(player) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(player)) createBlipAttachedTo ( player, 0, 2, r,g,b ) elseif ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam1(player) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(player)) createBlipAttachedTo ( player, 0, 2, r,g,b ) elseif ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end you will find "1" near each getPlayerTeam remove it. Link to comment
Resmurf Posted June 11, 2011 Author Share Posted June 11, 2011 get a error" 'then' expected near 'kw2' Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 i fixed it check it again and dont forget to remove the "1" near each getPlayerTeam Link to comment
Resmurf Posted June 11, 2011 Author Share Posted June 11, 2011 Not working, theres no blips on the map. Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 any warnings? any errors? did you remove the "1" from each getPlayerTeam Link to comment
Resmurf Posted June 11, 2011 Author Share Posted June 11, 2011 yes i removed and no errors or warning Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 hmm i dont know but you can just set a timer that will get the player name tag color and set the blip color to it. Link to comment
JR10 Posted June 12, 2011 Share Posted June 12, 2011 try this function onResourceStart ( resource ) for id, player in ipairs( getElementsByType ( "player" ) ) do if getPlayerTeam1(player) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(player)) createBlipAttachedTo ( player, 0, 2, r,g,b ) else elseif ( players[player] ) then createBlipAttachedTo ( player, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( player, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam1(player) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(player)) createBlipAttachedTo ( player, 0, 2, r,g,b ) else elseif ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 you still added the 1 at the end of getPlayerTeam Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 Not working Resource 'playerblips' changed, reloading and starting [2011-06-12 12:24:23] Starting playerblips [2011-06-12 12:24:23] SCRIPT ERROR: playerblips\playerblips.lua:7: 'end' expected (to close 'if' at line 3) near 'elseif' [2011-06-12 12:24:23] WARNING: Loading script failed: playerblips\playerblips.lua:7: 'end' expected (to close 'if' at line 3) near 'elseif' [2011-06-12 12:24:23] playerblips restarted successfully Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 Try this function onResourceStart ( resource, client ) for id, client in ipairs( getElementsByType ( "client" ) ) do if getPlayerTeam" class="kw2">getPlayerTeam(client) ~= nil then local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(client)) createBlipAttachedTo ( client, 0, 2, r,g,b ) else elseif ( players[client] ) then createBlipAttachedTo ( client, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( client, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam1(client) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(client)) createBlipAttachedTo ( client, 0, 2, r,g,b ) else elseif ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) end end Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 should i remove the number1? Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 [2011-06-12 12:36:45] SCRIPT ERROR: playerblips\playerblips.lua:3: 'then' expected near 'kw2' [2011-06-12 12:36:45] WARNING: Loading script failed: playerblips\playerblips.lua:3: 'then' expected near 'kw2' [2011-06-12 12:36:45] playerblips restarted successfully Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 NVM add back the numbers then. Link to comment
JR10 Posted June 12, 2011 Share Posted June 12, 2011 dont add the numbers in the script remove it. Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 he said that the script doesn't work with or without the numbers. Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 i removed and got the same error test it by urself Link to comment
JR10 Posted June 12, 2011 Share Posted June 12, 2011 u just copied it f***cked up from here there is something wrong with getPlayerTeam using lua tags so you must remove those kw2 from your script Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 use [.code=text] [./code] please i just remove it or replace with something? Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 ok I found the reason try this: function onResourceStart ( resource, client ) for id, client in ipairs( getElementsByType ( "client" ) ) do if getPlayerTeam" class="kw2">getPlayerTeam class="kw2">getPlayerTeam(client) ~= nil then local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam(client)) createBlipAttachedTo ( client, 0, 2, r,g,b ) else elseif ( players[client] ) then createBlipAttachedTo ( client, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( client, 0, 2, color[1], color[2], color[3] ) end end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam1(client) ~= nil then local r, g, b = getTeamColor(getPlayerTeam1(client)) createBlipAttachedTo ( client, 0, 2, r,g,b ) else elseif ( players[source] ) then createBlipAttachedTo ( source, 0, 2, players[source][1], players[source][2], players[source][3] ) else createBlipAttachedTo ( source, 0, 2, color[1], color[2], color[3] ) 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