Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 (edited) i tested this, this has no error: function onResourceStart ( resource, source ) for id, source in ipairs( getElementsByType ( "source" ) ) do if getPlayerTeam" class="kw2">getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam" class="kw2">getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end Edited June 12, 2011 by Guest Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 forums is glitched put it with instead of [lua] cause i get KW2 with lua Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 ok here: function onResourceStart ( resource, source ) for id, source in ipairs( getElementsByType ( "source" ) ) do if getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end end function onPlayerSpawn ( spawnpoint ) if getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 no errors but theres no blips in the map Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 try this then: addEventHandler ( "onClientResourceStart", getRootElement(getThisResource()), function( resource, source ) for id, source in ipairs( getElementsByType ( "source" ) ) do if getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end end) addEventHandler ( "onPlayerSpawn",getRootElement(), function( spawnpoint ) if getPlayerTeam(source) ~= nil then local r, g, b = getTeamColor(getPlayerTeam(source)) createBlipAttachedTo ( source, 0, 2, r,g,b ) else 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 end) I added the Event Handlers so when the resource start the blip is on the person, and when the player spawns it moves with them. Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 (edited) nope still not working edit: nvm i got it working, i respawned Edited June 12, 2011 by Guest Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 i edited it again now try it. Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 they both work, thanks, just need the player to spawn. Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 ok Edit: Do you mean the one in the script or you want the player to spawn? Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 no i mean, the script requires spawn to start working Link to comment
Jaysds1 Posted June 12, 2011 Share Posted June 12, 2011 ok Edit: here: addEventHandler ( "onPlayerJoin",getResource(getThisResource()), function() spawnPlayer (client, x, y, z, 0, math.random (1,288), 0, 0, teamF) end) Link to comment
Resmurf Posted June 12, 2011 Author Share Posted June 12, 2011 one problem when u change team, the color don't change. only if you respawn and if you logout the blips stay where u logged Link to comment
will briggs Posted June 13, 2011 Share Posted June 13, 2011 Please dont double post, use edit And you will need to make a fuction that when a players team is changed it refreshes the the blips module, BTW we wont spoon feed it to you, Go on the Wiki and look https://wiki.multitheftauto.com Link to comment
JR10 Posted June 13, 2011 Share Posted June 13, 2011 Your blips is created succesfully? , if so then , set a timer that will get the player name tag color and set the player blip to it like this: this script doesnt include creating the blip only change it's color so you must add it to your script. playerTimer = {} addEventHandler('onResourceStart', resourceRoot, function() for i, v in ipairs(getElementsByType('player')) do playerTimer[v] = setTimer(updatePlayerBlip, 1000, 0, v) end end ) addEventHandler('onPlayerSpawn', root, function() function(source) playerTimer[source] = setTimer(updatePlayerBlip, 1000, 0, source) end end ) function getPlayerBlip(src) if src then local attached = getAttachedElements ( src ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then return element end end end end end function updatePlayerBlip(src) if src then if not isPedDead(src) then if getPlayerBlip(src) then local r, g, b = getPlayerNametagColor(src) setBlipColor(getPlayerBlip(src), r, g, b, 255) end end end end addEventHandler('onPlayerQuit', root, function() if isTimer(playerTimer[source]) then killTimer(playerTimer[source]) end end ) addEventHandler('onPlayerWasted', root, function() if isTimer(playerTimer[source]) then killTimer(playerTimer[source]) end end ) And dont double post. Link to comment
Castillo Posted June 13, 2011 Share Posted June 13, 2011 okEdit: here: addEventHandler ( "onPlayerJoin",getResource(getThisResource()), function() spawnPlayer (client, x, y, z, 0, math.random (1,288), 0, 0, teamF) end) What is that? getResource(getThisResource()) ? I personally don't get what did you do here... Maybe you meant, getResourceRootElement(getThisResource()) ? Link to comment
Jaysds1 Posted June 13, 2011 Share Posted June 13, 2011 (edited) I just notice I messed up local x = POSITION OF PLAYER local y = POSITION OF PLAYER local z = POSITION OF PLAYER addEventHandler ( "onPlayerJoin",getRootElement(), function() spawnPlayer (client, x, y, z, 0, math.random (0,288), 0, 0) end) Edited June 13, 2011 by Guest Link to comment
Castillo Posted June 13, 2011 Share Posted June 13, 2011 Well, actually 'teamF' is not defined also if i'm right, maybe it should be 'nil' instead? P.S: If you want to correct that, you better EDIT your older post. Link to comment
Jaysds1 Posted June 13, 2011 Share Posted June 13, 2011 thanks again i copied my spawn code. 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