Dentos Posted September 17, 2014 Share Posted September 17, 2014 So I made this script that only allows you to see only your team members on map but I get this error in debugscript 3 ERROR: Loading script failed:gangblipps/playerblips.lua:10: 'then' expected near '=' root = getRootElement () color = { 0, 255, 0 } players = {} resourceRoot = getResourceRootElement ( getThisResource () ) players = { } function onResourceStart ( resource ) local team = getPlayerTeam ( source ) if player = team then players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) else destroyElement(blip) end end end function onPlayerSpawn ( spawnpoint ) local team = getPlayerTeam ( source ) if player = team then players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) else destroyElement(blip) end end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end oh im using castillos gang system idk if that has anything to do with it not working Im still learning so sorry if I made a stupid mistake Link to comment
Anubhav Posted September 17, 2014 Share Posted September 17, 2014 I'll tell you what to do. I don't want to post code and make a mistake. Do you see the if statment? Add a = after player. It should be if player == team instead of if player = team! Link to comment
Dentos Posted September 17, 2014 Author Share Posted September 17, 2014 So I did what you said and I removed few end and now I get no error but it still dosent work root = getRootElement () color = { 0, 255, 0 } players = {} resourceRoot = getResourceRootElement ( getThisResource () ) players = { } function onResourceStart ( resource ) local team = getPlayerTeam ( source ) if player == team then players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) else destroyElement(blip) end end function onPlayerSpawn ( spawnpoint ) local team = getPlayerTeam ( source ) if player == team then players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) else destroyElement(blip) end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end end theres script with no errors but no idea why it dosent work Link to comment
Et-win Posted September 17, 2014 Share Posted September 17, 2014 if player == team then 'player' is not defined. Link to comment
Dentos Posted September 18, 2014 Author Share Posted September 18, 2014 How to I define sorry im kinda new I trired adding ' ' on player --> 'player' didnt work Link to comment
DeVo Posted September 18, 2014 Share Posted September 18, 2014 color = { 0, 255, 0 } resourceRoot = getResourceRootElement ( getThisResource () ) players = { } function onResourceStart ( ) for i, plr in ipairs(getElementsByType("player")) do local team = getPlayerTeam ( plr ) if team then local r, g, b = getPlayerNameTagColor(plr) players [ plr ] = createBlipAttachedTo ( plr, 0, 2, r, g, b, 255 ) end end end function onPlayerSpawn ( ) local team = getPlayerTeam ( source ) if team then players [ player ] = createBlipAttachedTo ( player, 0, 2, r, g, b, 255 ) end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end end This one is fixed. I recommend you to add event when player change his team the blip reloads to take the new color. Link to comment
Dentos Posted September 18, 2014 Author Share Posted September 18, 2014 Dosent work maybe dosent work cuz im using catillos gang system? Link to comment
Anubhav Posted September 18, 2014 Share Posted September 18, 2014 Sir DevO, Do you know even what you posted? It will give a error @ Dentos There's a typo and local functions mistake. color = { 0, 255, 0 } resourceRoot = getResourceRootElement ( getThisResource () ) players = { } function onResourceStart ( ) for i, plr in ipairs(getElementsByType("player")) do local team = getPlayerTeam ( plr ) if team then local r, g, b = getPlayerNametagColor(plr) -- here is one typo fix players [ plr ] = createBlipAttachedTo ( plr, 0, 2, r, g, b, 255 ) end end end function onPlayerSpawn ( ) local team = getPlayerTeam ( source ) local r, g, b = getPlayerNametagColor( source ) if team then players [ source ] = createBlipAttachedTo ( source, 0, 2, r, g, b, 255 ) end end addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn ) function destroyBlips ( totalammo, killer, killerweapon ) destroyBlipsAttachedTo ( source ) end addEventHandler ( "onPlayerQuit", root, destroyBlips ) addEventHandler ( "onPlayerWasted", root, destroyBlips ) function destroyBlipsAttachedTo ( player ) local attached = getAttachedElements ( player ) if ( attached ) then for _, element in ipairs ( attached ) do if ( getElementType ( element ) == "blip" ) then destroyElement ( element ) end end end end Link to comment
DeVo Posted September 18, 2014 Share Posted September 18, 2014 Sir DevO, Do you know even what you posted? It will give a error @ Dentos There's a typo and local [/lua] Don't come to my posts then reply with childish way or you will get reported --- USER WAS WARNED FOR THIS POST --- Link to comment
Dentos Posted September 18, 2014 Author Share Posted September 18, 2014 So the script work but it only does the same as my old script show every player in map to everyone when you die or reconnect Im trying to make it so only gang members can see eachother Link to comment
DeVo Posted September 18, 2014 Share Posted September 18, 2014 So the script work but it only does the same as my old script show every player in map to everyone when you die or reconnect Im trying to make it so only gang members can see eachother Easy, Add condition for the "plr" must be in the same group. Add an event when the player joins the group. Then trigger it here with reloading the blips so the new gang member will be added. OFF-Topic: Always Ignore anyone who wants to troll other, not to help you. Link to comment
Dentos Posted September 20, 2014 Author Share Posted September 20, 2014 please help me out with script I beg you its just im not very good on lua and its last thing I need for my server please I been stuck on this more than a month Link to comment
Anubhav Posted September 20, 2014 Share Posted September 20, 2014 DeVo @ I don't think you understood him. Dentos @ setElementVisibleTo in a loop would do it. 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