Jump to content

Blips no work


xeon17

Recommended Posts

  
  
function onSpawn ( ) 
    takeAllWeapons ( source ) 
    giveWeapon ( source, 24, 100 ) 
    local playerTeam = getPlayerTeam(source)         
    if (playerTeam) then   
    local r, g, b = getTeamColor(playerTeam) 
    local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
    setPedStat ( source, 73, 1000 ) 
    setPedStat ( source, 75, 1000 ) 
    setPedStat ( source, 71, 1000 ) 
    setPedStat ( source, 75, 1000 ) 
    giveWeapon ( source, 26, 100 ) 
    setPedStat ( source, 77, 1000 ) 
    setPedStat ( source, 78, 1000 ) 
    giveWeapon ( source, 32, 100 ) 
    giveWeapon ( source, 31, 150 ) 
    giveWeapon ( source, 46, 200 ) 
    givePlayerMoney ( source, 5000 ) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), onSpawn ) 
  
function onPlayerQuit () 
    destroyBlipsAttachedTo ( source ) 
end 
  
function onPlayerWasted ( ) 
destroyBlipsAttachedTo ( source ) 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), onPlayerQuit ) 
  
function Blip ( ) 
local playerTeam = getPlayerTeam(source)         
if ( not playerTeam) then   
local MeuBlip = createBlipAttachedTo ( source, 0 , 2 , 255,255,255 ) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), onSpawn ) 
  

Blips for players without gang no work , and when players quit they blip no destroy.. can someone help me please

Link to comment
  
  
local r, g, b 
local blip 
    function onSpawn ( ) 
        takeAllWeapons ( source ) 
        giveWeapon ( source, 24, 100 ) 
        local playerTeam = getPlayerTeam(source)         
        if (playerTeam) then   
            r, g, b = getTeamColor(playerTeam) 
            blip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
            setPedStat ( source, 73, 1000 ) 
            setPedStat ( source, 75, 1000 ) 
            setPedStat ( source, 71, 1000 ) 
            setPedStat ( source, 75, 1000 ) 
            giveWeapon ( source, 26, 100 ) 
            setPedStat ( source, 77, 1000 ) 
            setPedStat ( source, 78, 1000 ) 
            giveWeapon ( source, 32, 100 ) 
            giveWeapon ( source, 31, 150 ) 
            giveWeapon ( source, 46, 200 ) 
            givePlayerMoney ( source, 5000 ) 
        else 
            r,g,b = 255,255,255 
            blip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
        end 
    end 
    addEventHandler ( "onPlayerSpawn", getRootElement(), onSpawn ) 
  
    function onPlayerQuit () 
        destroyElement ( blip ) 
    end 
      
    function onPlayerWasted ( ) 
        destroyElement ( blip ) 
    end 
    addEventHandler ( "onPlayerQuit", getRootElement(), onPlayerQuit ) 
      

Link to comment

I'm sure KRZO's one will not work, here:

local pBlips = {} 
  
function onSpawn ( ) 
    takeAllWeapons ( source ) 
    giveWeapon ( source, 24, 100 ) 
    local playerTeam = getPlayerTeam(source)         
    if (playerTeam) and not pBlips[source] then   
        local r, g, b = getTeamColor(playerTeam) 
        local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
        pBlips[source] = myBlip 
        setPedStat ( source, 73, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 71, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 77, 1000 ) 
        setPedStat ( source, 78, 1000 ) 
        giveWeapon ( source, 26, 100 ) 
        giveWeapon ( source, 32, 100 ) 
        giveWeapon ( source, 31, 150 ) 
        giveWeapon ( source, 46, 200 ) 
        givePlayerMoney ( source, 5000 ) 
    elseif pBlips[source] then 
        destroyPlayerBlip(source) 
    end 
end 
  
function destroyPlayerBlip(pElement) 
    local theElement = (pElement and getElementType(pElement) == 'player' and pElement) or source 
    if pBlips[theElement] then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) 
addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) 
addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) 

Link to comment

none of your two code work :/ nothing happen

Krzo's one have a bug

[2014-05-16 13:31:39] WARNING: [ST]Spawn\Spawn.lua:28: Bad argument @ 'getElementType' [Expected element at argument 1, got number '0'] 
[2014-05-16 13:31:50] ERROR: scores\scores.lua:93: attempt to perform arithmetic on a boolean value 
[2014-05-16 13:31:50] WARNING: [ST]Spawn\Spawn.lua:28: Bad argument @ 'getElementType' [Expected element at argument 1, got number '233'] 

Link to comment
local pBlips = {} 
  
function onSpawn ( ) 
    takeAllWeapons ( source ) 
    giveWeapon ( source, 24, 100 ) 
    local playerTeam = getPlayerTeam(source)         
    if (playerTeam) and not pBlips[source] then   
        local r, g, b = getTeamColor(playerTeam) 
        local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
        pBlips[source] = myBlip 
        setPedStat ( source, 73, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 71, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 77, 1000 ) 
        setPedStat ( source, 78, 1000 ) 
        giveWeapon ( source, 26, 100 ) 
        giveWeapon ( source, 32, 100 ) 
        giveWeapon ( source, 31, 150 ) 
        giveWeapon ( source, 46, 200 ) 
        givePlayerMoney ( source, 5000 ) 
    elseif pBlips[source] then 
        destroyPlayerBlip(source) 
    end 
end 
  
function destroyPlayerBlip(pElement) 
    local theElement = source or pElement 
    if pBlips[theElement] then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) 
addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) 
addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) 

Link to comment

no work :/ nothing in debug this time.

local pBlips = {} 
  
function onSpawn ( ) 
        takeAllWeapons ( source ) 
        setPlayerMoney ( source, 0 ) 
        giveWeapon ( source, 24, 100 ) 
        setPedStat ( source, 73, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 71, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 77, 1000 ) 
        setPedStat ( source, 78, 1000 ) 
        giveWeapon ( source, 26, 100 ) 
        giveWeapon ( source, 32, 100 ) 
        giveWeapon ( source, 31, 150 ) 
        giveWeapon ( source, 46, 200 ) 
        givePlayerMoney ( source, 5000 ) 
        local playerTeam = getPlayerTeam(source)         
        if (playerTeam) and not pBlips[source] then   
        local r, g, b = getTeamColor(playerTeam) 
        local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
        pBlips[source] = myBlip 
        elseif pBlips[source] then 
        destroyPlayerBlip(source) 
    end 
end 
  
function destroyPlayerBlip(pElement) 
    local theElement = source or pElement 
    if pBlips[theElement] then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) 
addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) 
addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) 

Link to comment

You can try this:

local pBlips = {} 
  
function onSpawn ( p ) 
    if ( not source or not isElement ( source ) and p and isElement ( p ) ) then 
        source = p 
    end 
        takeAllWeapons ( source ) 
        setPlayerMoney ( source, 0 ) 
        giveWeapon ( source, 24, 100 ) 
        setPedStat ( source, 73, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 71, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 77, 1000 ) 
        setPedStat ( source, 78, 1000 ) 
        giveWeapon ( source, 26, 100 ) 
        giveWeapon ( source, 32, 100 ) 
        giveWeapon ( source, 31, 150 ) 
        giveWeapon ( source, 46, 200 ) 
        givePlayerMoney ( source, 5000 ) 
        local playerTeam = getPlayerTeam(source)         
        if (playerTeam) and not pBlips[source] then   
        local r, g, b = getTeamColor(playerTeam) 
        local myBlip = createBlipAttachedTo ( source, 0 , 2 , r,g,b ) 
        pBlips[source] = myBlip 
        elseif pBlips[source] then 
        destroyPlayerBlip(source) 
    end 
end 
  
function destroyPlayerBlip(pElement) 
    local theElement = source or pElement 
    if pBlips[theElement] then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) 
addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) 
addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) 
  
addEventHandler ( 'onResourceStart', resourceRoot, function ( ) 
    for _, p in pairs ( getElementsByType ( "player" ) ) do 
        onSpawn ( p ) 
    end 
end )  

Link to comment

I'll post the full code , because i edited the script a little. I tried to make that players without gang have a blip too.

but no work , of couse :/

local pBlips = {} 
  
function onSpawn ( p ) 
    if ( not source or not isElement ( source ) and p and isElement ( p ) ) then 
        source = p 
    end 
        takeAllWeapons ( source ) 
        setPlayerMoney ( source, 0 ) 
        giveWeapon ( source, 24, 100 ) 
        setPedStat ( source, 73, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 71, 1000 ) 
        setPedStat ( source, 75, 1000 ) 
        setPedStat ( source, 77, 1000 ) 
        setPedStat ( source, 78, 1000 ) 
        giveWeapon ( source, 26, 100 ) 
        giveWeapon ( source, 32, 100 ) 
        giveWeapon ( source, 31, 150 ) 
        giveWeapon ( source, 46, 200 ) 
        givePlayerMoney ( source, 5000 ) 
        local playerTeam = getPlayerTeam(source)         
        if (playerTeam) and not pBlips[source] then   
        local r, g, b = getTeamColor(playerTeam) 
        local myBlip = createBlipAttachedTo ( source, 0 , 10 , r,g,b ) 
        pBlips[source] = myBlip 
        elseif pBlips[source] then 
        destroyPlayerBlip(source) 
    end 
end 
  
function destroyPlayerBlip(pElement) 
    local theElement = source or pElement 
    if pBlips[theElement] then 
        destroyElement(pBlips[theElement]) 
        pBlips[theElement] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(), onSpawn) 
addEventHandler("onPlayerQuit", getRootElement(), destroyPlayerBlip) 
addEventHandler("onPlayerWasted", getRootElement(), destroyPlayerBlip) 
  
addEventHandler ( 'onResourceStart', resourceRoot, function ( ) 
    for _, p in pairs ( getElementsByType ( "player" ) ) do 
        onSpawn ( p ) 
    end 
end ) 
  
function Blip ( ) 
local playerTeam = getPlayerTeam(source)         
if ( not playerTeam) then   
local MeuBlip = createBlipAttachedTo ( source, 0 , 2 , 255,255,255 ) 
end 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), onSpawn ) 
  

ERROR with code of xMADEx :

[2014-05-19 08:06:16] WARNING: [ST]Spawn\Spawn.lua:21: Bad 'player' pointer @ 'getPlayerTeam'(1) 

Link to comment
local pBlips = {} 
  
function onSpawn(player) 
    takeAllWeapons(player) 
    setPlayerMoney(player, 0) 
    giveWeapon(player, 24, 100) 
    setPedStat(player, 73, 1000) 
    setPedStat(player, 75, 1000) 
    setPedStat(player, 71, 1000) 
    setPedStat(player, 75, 1000) 
    setPedStat(player, 77, 1000) 
    setPedStat(player, 78, 1000) 
    giveWeapon(player, 26, 100) 
    giveWeapon(player, 32, 100) 
    giveWeapon(player, 31, 150) 
    giveWeapon(player, 46, 200) 
    givePlayerMoney(player, 5000) 
    if pBlips[player] then  
        destroyElement(pBlips[player]) 
        pBlips[player] = nil 
    end 
    local playerTeam = getPlayerTeam(player)         
    if (playerTeam) then 
        local r, g, b = getTeamColor(playerTeam) 
        pBlips[player] = createBlipAttachedTo(player, 0, 10, r, g, b) 
    else  
        pBlips[player] = createBlipAttachedTo(player, 0, 10, 255, 255, 255) 
    end 
end 
  
function destroyPlayerBlip() 
    if pBlips[source] then 
        destroyElement(pBlips[source]) 
        pBlips[source] = nil 
    end 
end 
  
addEventHandler("onPlayerSpawn", root, function() onSpawn(source) end) 
addEventHandler("onPlayerQuit", root, destroyPlayerBlip) 
addEventHandler("onPlayerWasted", root, destroyPlayerBlip) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for _, p in ipairs(getElementsByType("player")) do 
        onSpawn(p) 
    end 
end) 

Link to comment

i think that should to be better and what do you want ;)

local stats = {73, 75, 71, 77, 78} 
local weapons = {[24] = 100, [26] = 100, [32] = 100, [31] = 150, [46] = 200} 
local pBlips = {} 
  
addEventHandler("onPlayerSpawn", root, 
function (source) 
    takeAllWeapons(source) 
    setPlayerMoney(source, 0) 
    givePlayerMoney(source, 5000) 
    for _, stat in ipairs(stats) do 
        setPedStat(source, 73, 1000) 
    end 
    for weapon, ammo in pairs(weapons) do 
        giveWeapon(source, weapon, ammo) 
    end 
    pBlips[source] = createBlipAttachedTo(source, 0, 2) 
end 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for _, player in ipairs(getElementsByType("player")) do 
        if not (isPlayerDead(player)) then 
            pBlips[source] = createBlipAttachedTo(player, 0, 2) 
        end 
    end 
end) 
-- Blip system 
setTimer(function() 
    for player, blip in ipairs(pBlips) do 
        if (isElement(player)) and not (isPlayerDead(player)) then 
            local playerTeam = getPlayerTeam(player) 
            if (playerTeam) then 
                local r, g, b = getTeamColor(playerTeam) 
                setBlipColor(blip, r, g, b) 
            else 
                setBlipColor(blip, 255, 255, 255) 
            end 
        else 
            destroyElement(blip) 
            pBlips[player] = nil 
        end 
    end 
end, 5000, 0) 
  

Link to comment

Try this.

local stats = {73, 75, 71, 77, 78} 
local weapons = {[24] = 100, [26] = 100, [32] = 100, [31] = 150, [46] = 200} 
local pBlips = {} 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    takeAllWeapons(source) 
    setPlayerMoney(source, 5000) 
    --givePlayerMoney(source, 5000) 
    for _, stat in ipairs(stats) do 
        setPedStat(source, stat, 1000) 
    end 
    for weapon, ammo in pairs(weapons) do 
        giveWeapon(source, weapon, ammo) 
    end 
    if not pBlips[source] then 
        pBlips[source] = createBlipAttachedTo(source, 0, 2) 
    end 
end) 
  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    for _, player in ipairs(getElementsByType("player")) do 
        if not (isPlayerDead(player)) then 
            pBlips[player] = createBlipAttachedTo(player, 0, 2) 
        end 
    end 
end) 
  
-- Blip system 
setTimer(function() 
    for player, blip in pairs(pBlips) do 
        if (isElement(player)) then 
            local playerTeam = getPlayerTeam(player) 
            if (playerTeam) then 
                local r, g, b = getTeamColor(playerTeam) 
                setBlipColor(blip, r, g, b, 255) 
            else 
                setBlipColor(blip, 255, 255, 255, 255) 
            end 
        else 
            destroyElement(blip) 
            pBlips[player] = nil 
        end 
    end 
end, 5000, 0) 

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