Jump to content

Help please? with this small script


Dentos

Recommended Posts

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

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
  
    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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...