mastermax777 Posted May 17, 2011 Share Posted May 17, 2011 i want to make a blip appear for ALL player expect myself. this is what i tried so far... blip = createBlipAttachedTo (source, 56) i = getElementsByType ( "player" ) for k, v in ipairs(i) do if(i ~= source) then setElementVisibleTo ( blip, v, false ) end end no errors but i can still see the blip on the mini map over myself Link to comment
Castillo Posted May 17, 2011 Share Posted May 17, 2011 blip = createBlipAttachedTo (source, 56) setElementVisibleTo ( blip, source, false ) players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end Link to comment
karlis Posted May 17, 2011 Share Posted May 17, 2011 blip = createBlipAttachedTo (sourceP, 56) setElementVisibleTo ( blip, sourceP, false ) better don't use variable source, as it is sometime defined by defaults. Link to comment
mastermax777 Posted May 17, 2011 Author Share Posted May 17, 2011 sourceP?? it works but where do i define it ?? it gives me warnings ... (bad argument at ...) and with source it doesnt disappear o_o Link to comment
Try Posted May 17, 2011 Share Posted May 17, 2011 I Don't Tested but do this function createblip() random = getPlayerFromName(getRandomPlayer()) createBlipAttachedTo(random, 41) end -- addEventHandler("onPlayerJoin",getRootElement(),createblip) or addCommandHandler("randomblip",createblip) I think its this you need Cya later, Maaaaria. Link to comment
mastermax777 Posted May 17, 2011 Author Share Posted May 17, 2011 I Don't Tested but do this No. this is my code Solidsnake14... --local sourceP blip = createBlipAttachedTo (sourceP, 56) setElementVisibleTo ( blip, sourceP, false ) players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end Link to comment
AGENT_STEELMEAT Posted May 17, 2011 Share Posted May 17, 2011 To help you, we need the ENTIRE script (mainly the function and any events that trigger it). Where is sourceP defined? Link to comment
Castillo Posted May 18, 2011 Share Posted May 18, 2011 I think he's a newbie? because if that's the full script, he's forgeting some things. addCommandHandler("blip", function (sourceP) local blip = createBlipAttachedTo (sourceP, 56) setElementVisibleTo ( blip, sourceP, false ) end) I think that should work. Link to comment
AGENT_STEELMEAT Posted May 18, 2011 Share Posted May 18, 2011 Okay, if you are trying to create a single blip that is shown for ALL player EXCEPT for one player, try this. NOTE: this code snippet assumes that source is a player that triggered some event. Whether or not this is what is going in I am unsure since you won't show us your full script. local blip = createBlipAttachedTo (source, 56) --Create the blip - it will be visible for all players.. setElementVisibleTo(blip, source, false ) --Hide the blip. Also, ignore the weird "sourceP" advice - that makes no sense. Also note: this is just a snippet - it wont work just on it's own, so I assume you have this all within a function. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 Okay, if you are trying to create a single blip that is shown for ALL player EXCEPT for one player, try this.NOTE: this code snippet assumes that source is a player that triggered some event. Whether or not this is what is going in I am unsure since you won't show us your full script. local blip = createBlipAttachedTo (source, 56) --Create the blip - it will be visible for all players.. setElementVisibleTo(blip, source, false ) --Hide the blip. Also, ignore the weird "sourceP" advice - that makes no sense. Also note: this is just a snippet - it wont work just on it's own, so I assume you have this all within a function. it does make sense.some functions/events have build in source argument, and if you define something else with it it overwrites. therefore, for example, you wont be able to know, what player triggered some event. Link to comment
AGENT_STEELMEAT Posted May 18, 2011 Share Posted May 18, 2011 thats the point - source is the player he wants to attatch the blip to, and hide the blip from... Link to comment
mastermax777 Posted May 18, 2011 Author Share Posted May 18, 2011 MY QUESTION IS, HOW TO define SourceP ffs cant u see i did '--local sourceP' in my script but it doesnt work?!? function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) if(not firstspawn[source]) then firstspawn[source] = true; givePlayerMoney ( source, 10000 ) local sourceP blip = createBlipAttachedTo (sourceP, 56) setElementVisibleTo ( blip, sourceP, false ) players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end end end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) Happy? Link to comment
Castillo Posted May 18, 2011 Share Posted May 18, 2011 function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) if(not firstspawn[source]) then firstspawn[source] = true; givePlayerMoney ( source, 10000 ) blip = createBlipAttachedTo (source, 56) setElementVisibleTo ( blip, source, false ) end end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) You don't need sourceP here, since source is already the player element who just spawned. Link to comment
AGENT_STEELMEAT Posted May 18, 2011 Share Posted May 18, 2011 mastermax, sourceP isn't relevant, in fact it was really bad advice. You want to use SOURCE, and it is already defined by the event onPlayerSpawn. Also, for future reference, you need to post ALL of the relevant info (either the entire script or the single function and event). Link to comment
mastermax777 Posted May 18, 2011 Author Share Posted May 18, 2011 source doesnt work... i can still see myself function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) if(not firstspawn[source]) then firstspawn[source] = true; givePlayerMoney ( source, 10000 ) blip = createBlipAttachedTo (source, 56) setElementVisibleTo ( blip, source, false ) players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end end giveWeapon (source, 31, 400) giveWeapon (source, 26, 200) giveWeapon (source, 9, 1) giveWeapon (source, 29, 400) end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 source doesnt work... i can still see myself function player_Spawn ( posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension ) if(not firstspawn[source]) then firstspawn[source] = true; givePlayerMoney ( source, 10000 ) blip = createBlipAttachedTo (source, 56) setElementVisibleTo ( blip, source, false ) players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end end giveWeapon (source, 31, 400) giveWeapon (source, 26, 200) giveWeapon (source, 9, 1) giveWeapon (source, 29, 400) end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) thats exact reason you don't want to use source as any other arguments, cuz it overwrites normal ones. and forget this: players = getElementsByType ( "player" ) for k, v in ipairs(players) do if(v ~= source) then setElementVisibleTo ( blip, v, true ) end end this is not needed, it is set visible by default. Link to comment
AGENT_STEELMEAT Posted May 18, 2011 Share Posted May 18, 2011 Karlis, that dosent make any sense - source is the player that the blip needs to be hidden from. So you use setElementVisibleTo(blip, source, false). Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 Karlis, that dosent make any sense - source is the player that the blip needs to be hidden from. So you use setElementVisibleTo(blip, source, false). wait, isn't the source defined anywhere else? oh i see, sry, tought he did define smthing like source=... edit: so this should still work just fine firstspawn={ } function player_Spawn () if (not firstspawn[source]) then firstspawn[source] = true givePlayerMoney ( source, 10000 ) local blip = createBlipAttachedTo (source, 56) setElementVisibleTo ( blip, source, false ) end giveWeapon (source, 31, 400) giveWeapon (source, 26, 200) giveWeapon (source, 9, 1) giveWeapon (source, 29, 400) end addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn ) Link to comment
AGENT_STEELMEAT Posted May 18, 2011 Share Posted May 18, 2011 The event "onPlayerSpawn" defines source as the player who just spawned, and passes it along to player_Spawn (the handler function) automatically. So source is defined automatically. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 The event "onPlayerSpawn" defines source as the player who just spawned, and passes it along to player_Spawn (the handler function) automatically. So source is defined automatically. i did understand that all the time, just thought its overwritten after that, as i said, nvm, sorry for that. 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