Jump to content

Fix Code


SoMoRay

Recommended Posts

for _, playersP in ipairs ( getPlayersInTeam ( getTeamFromName ( "Police" ) ) ) do 
  
    createBlipAttachedTo ( playersP , 0 , 2 , 0 , 0 , 255 , 255 ) 
  
end 

You had put 'playerP' instead of 'playersP'.

still not do blips for it's ! :(( :wink:

Link to comment

see guys this is the full code for createTeam with the blip

addEventHandler("onResourceStart",resourceRoot, 
  
function() 
  
Team2 = createTeam ( "Police", 0, 0, 255 ) 
  
setTeamFriendlyFire ( Team2, false ) 
  
for _, playersP in ipairs ( getPlayersInTeam ( getTeamFromName ( "Police" ) ) ) do 
  
 createBlipAttachedTo ( playersP , 0 , 2 , 0 , 0 , 255 , 255  ) 
  
    end 
end) 

Edit :

there is no any bug in debugscript

i be crazy with him I saw non eror but I don't

know why he didn't work fine ! .

Link to comment

try this:

addEventHandler("onResourceStart",resourceRoot,function() 
    if source~=resource then return end 
    local policeTeam = createTeam ( "Police", 0, 0, 255 ) 
    setTeamFriendlyFire ( policeTeam, false ) 
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
    if #players == 0 then return end --ends the script if there's no players on the police team 
    for _, player in ipairs ( players ) do 
        createBlipAttachedTo ( player , 0 , 2 , 0 , 0 , 255 , 255  ) 
    end 
end) 

Link to comment
try this:
addEventHandler("onResourceStart",resourceRoot,function() 
    if source~=resource then return end 
    local policeTeam = createTeam ( "Police", 0, 0, 255 ) 
    setTeamFriendlyFire ( policeTeam, false ) 
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
    if #players == 0 then return end --ends the script if there's no players on the police team 
    for _, player in ipairs ( players ) do 
        createBlipAttachedTo ( player , 0 , 2 , 0 , 0 , 255 , 255  ) 
    end 
end) 

same proplem not make blip

Link to comment
Post what you did.

   local Team = createTeam ( "Alone", 255, 0, 0 ) 
    setTeamFriendlyFire ( Team, false ) 
     
    local policeTeam = createTeam ( "Police", 0, 0, 255 ) 
  
    setTeamFriendlyFire ( policeTeam, false ) 
     
addEventHandler("onResourceStart",resourceRoot,function() 
  
    if source~=resource then return end 
     
    setTeamFriendlyFire ( Team, false ) 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Alone" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 58 , 2 , 255 , 0 , 0 , 255  ) 
  
    end 
  
end) 
  
  
  
 -------------------- police 
addEventHandler("onResourceStart",resourceRoot,function() 
  
    if source~=resource then return end 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 58 , 2 , 0 , 0 , 255 , 255  ) 
  
    end 
  
end) 
Link to comment
That's because the blip will shown for how have a police team when the resource start use a timer :
setTimer 

Are You Main I Do Like that ? :

  local Team = createTeam ( "Alone", 255, 0, 0 ) 
    setTeamFriendlyFire ( Team, false ) 
     
    local policeTeam = createTeam ( "Police", 0, 0, 255 ) 
  
    setTeamFriendlyFire ( policeTeam, false ) 
     
  
   addEventHandler("onResourceStart",resourceRoot, 
   function () 
    
   setTimer(BlipT,1000,1) 
    
   setTimer(BlipP,1000,1) 
    
   end 
   ) 
    
  
    function BlipT() 
  
    if source~=resource then return end 
     
    setTeamFriendlyFire ( Team, false ) 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Alone" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 58 , 2 , 255 , 0 , 0 , 255  ) 
  
    end 
  
end 
  
  
  
 -------------------- police 
  
 function BlipP() 
  
    if source~=resource then return end 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 58 , 2 , 0 , 0 , 255 , 255  ) 
  
    end 
  
end 
Link to comment
Post the whole script.

local Team = createTeam ( "Alone", 255, 0, 0 ) 
    setTeamFriendlyFire ( Team, false ) 
     
    local policeTeam = createTeam ( "Police", 0, 0, 255 ) 
  
    setTeamFriendlyFire ( policeTeam, false ) 
     
  
   addEventHandler("onResourceStart",resourceRoot, 
   function () 
   
   setTimer(BlipT,1000,0) 
  
   setTimer(BlipP,1000,0) 
  
   end 
   ) 
    
  
    function BlipT() 
  
    if source~=resource then return end 
     
    setTeamFriendlyFire ( Team, false ) 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Alone" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 0 , 2 , 255 , 0 , 0 , 255  ) 
  
    end 
  
end 
  
  
  
 -------------------- police 
  
 function BlipP() 
  
    if source~=resource then return end 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
  
    if #players == 0 then return end --ends the script if there's no players on the police team 
  
    for _, player in ipairs ( players ) do 
  
        createBlipAttachedTo ( player , 0 , 2 , 0 , 0 , 255 , 255  ) 
  
    end 
  
end 
  
addEvent ( "spawnPed", true ) 
  
addEventHandler ( "spawnPed", root, 
  
    function ( thePed ) 
  
        if ( thePed == 2 ) then 
  
            spawnPlayer ( source, 1485.0311279297, -2234.9086914063, 13.546875, 0, 2, 0, 0, Team ) 
  
            setCameraTarget ( source, source ) 
  
        elseif ( thePed == 280 ) then 
  
            spawnPlayer ( source, 1568.5963134766, -1691.4530029297, 5.890625, 0, 280, 0, 0, policeTeam ) 
  
            setCameraTarget ( source, source ) 
  
        end 
  
    end 
  
) 
------------------------------- kill 
------------------------------------ 
function commitSuicide ( sourcePlayer ) 
  
    killPed ( sourcePlayer, sourcePlayer ) 
     
end 
addCommandHandler ( "kill", commitSuicide ) 
------------------------------------ 
  
Link to comment

There's no need to use two timers, you can use just one.

addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        setTimer ( blips, 1000, 0 ) 
        Team = createTeam ( "Alone", 255, 0, 0 ) 
        setTeamFriendlyFire ( Team, false ) 
        policeTeam = createTeam ( "Police", 0, 0, 255 ) 
        setTeamFriendlyFire ( policeTeam, false ) 
    end 
) 
  
function blips ( ) 
    local players = getPlayersInTeam ( getTeamFromName ( "Alone" ) ) 
    if ( #players > 0 ) then 
        for _, player in ipairs ( players ) do 
            createBlipAttachedTo ( player, 0, 2 , 255 , 0 , 0 , 255  ) 
        end 
    end 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
    if ( #players > 0 ) then 
        for _, player in ipairs ( players ) do 
            createBlipAttachedTo ( player , 0 , 2 , 0 , 0 , 255 , 255  ) 
        end 
    end 
end 
  
addEvent ( "spawnPed", true ) 
addEventHandler ( "spawnPed", root, 
    function ( thePed ) 
        if ( thePed == 2 ) then 
            spawnPlayer ( source, 1485.0311279297, -2234.9086914063, 13.546875, 0, 2, 0, 0, Team ) 
            setCameraTarget ( source, source ) 
        elseif ( thePed == 280 ) then 
            spawnPlayer ( source, 1568.5963134766, -1691.4530029297, 5.890625, 0, 280, 0, 0, policeTeam ) 
            setCameraTarget ( source, source ) 
        end 
    end  
) 
  
------------------------------- kill 
------------------------------------ 
function commitSuicide ( sourcePlayer ) 
    killPed ( sourcePlayer, sourcePlayer ) 
end 
addCommandHandler ( "kill", commitSuicide ) 

Link to comment
There's no need to use two timers, you can use just one.
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        setTimer ( blips, 1000, 0 ) 
        Team = createTeam ( "Alone", 255, 0, 0 ) 
        setTeamFriendlyFire ( Team, false ) 
        policeTeam = createTeam ( "Police", 0, 0, 255 ) 
        setTeamFriendlyFire ( policeTeam, false ) 
    end 
) 
  
function blips ( ) 
    setTeamFriendlyFire ( Team, false ) 
    local players = getPlayersInTeam ( getTeamFromName ( "Alone" ) ) 
    if ( #players > 0 ) then 
        for _, player in ipairs ( players ) do 
            createBlipAttachedTo ( player, 0, 2 , 255 , 0 , 0 , 255  ) 
        end 
    end 
  
    local players = getPlayersInTeam ( getTeamFromName ( "Police" ) ) 
    if ( #players > 0 ) then 
        for _, player in ipairs ( players ) do 
            createBlipAttachedTo ( player , 0 , 2 , 0 , 0 , 255 , 255  ) 
        end 
    end 
end 
  
addEvent ( "spawnPed", true ) 
addEventHandler ( "spawnPed", root, 
    function ( thePed ) 
        if ( thePed == 2 ) then 
            spawnPlayer ( source, 1485.0311279297, -2234.9086914063, 13.546875, 0, 2, 0, 0, Team ) 
            setCameraTarget ( source, source ) 
        elseif ( thePed == 280 ) then 
            spawnPlayer ( source, 1568.5963134766, -1691.4530029297, 5.890625, 0, 280, 0, 0, policeTeam ) 
            setCameraTarget ( source, source ) 
        end 
    end  
) 
  
------------------------------- kill 
------------------------------------ 
function commitSuicide ( sourcePlayer ) 
    killPed ( sourcePlayer, sourcePlayer ) 
end 
addCommandHandler ( "kill", commitSuicide ) 

There's no need to use setTeamFriendlyFire At blips function .

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