Jump to content

Ayuda con script de stats [Solucionado]


Razor64

Recommended Posts

Hola buen dia, bueno quisiera que me ayudaran con un scipr que estoy haciendo para que te de habilidad con el arma con la que mataste al zombies, es decir si matas a un zombie con una M4 te dara un punto en habilidad o stats, el problema es que si otro jugador tambien le da stats del arma usada sin que el mate ningun zombie es decir si yo mato zombie le da habilidad en el arma usada a todos en el server, cosa que no tiene que pasar ya busque varias forma de como arreglarlo pero nada mas no puedo, ademas de que tampoco conosco mucho de scripting y por eso les pido su ayuda, y una cosa mas si reinicio el resource o lo paro y lo cargo de nuevo se reinician todos los stats quisiera ver si tambien me pueden ayudar con eso. bueno espero me ayuden y muchas gracias por su atencion

a qui el codigo todo esto lo puse en server-side

  
local stat22 = 0 
local stat23 = 0 
local stat24 = 0 
local stat25 = 0 
local stat26 = 0 
local stat27 = 0 
local stat28 = 0 
local stat29 = 0 
local stat30 = 0 
local stat31 = 0 
local stat34 = 0 
  
  
  
  
------------ Pistola 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root,  
 function (killer, weapon)   
  if weapon == 22 then 
    givePlayerMoney(killer,10) 
    setPedStat (killer, 69, stat22)    
    stat22 = stat22 + 1 
  if (tonumber(getPedStat( killer, 69 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Pistola", killer, 255, 255, 255, true) 
  end    
 end 
end) 
  
  
------------ Silenced 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 23 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 70, stat23 ) 
    stat23 = stat23 + 1 
  if (tonumber(getPedStat( killer, 70 )) == 999) then 
        outputChatBox ( "#FFFF00#FFFF00Has conseguido la habilidad maxima en #FF0000Silenced", killer, 255, 255, 255, true) 
  end    
 end 
end) 
  
------------ Desert Eagle 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 24 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 71, stat24 ) 
    stat24 = stat24 + 1 
  if (tonumber(getPedStat( killer, 71 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Desert Eagle", killer, 255, 255, 255, true) 
  end    
 end 
end) 
  
------------ Escopeta 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 25 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 72, stat25 ) 
    stat25 = stat25 + 1 
  if (tonumber(getPedStat( killer, 72 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta", killer, 255, 255, 255, true) 
  end    
 end 
end) 
  
----------- Escopeta recortada 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 26 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 73, stat26 ) 
    stat26 = stat26 + 1 
  if (tonumber(getPedStat( killer, 73 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta Recortada", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- Spaz-12 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 27 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 74, stat27 ) 
    stat27 = stat27 + 1 
  if (tonumber(getPedStat( killer, 74 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta SPAZ-12", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- Uzi 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 28 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 75, stat28 ) 
    stat28 = stat28 + 1 
  if (tonumber(getPedStat( killer, 75 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Metralleta Uzi", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- MP5 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 29 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 76, stat29 ) 
    stat29 = stat29 + 1 
  if (tonumber(getPedStat( killer, 76 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Metralleta MP5", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- AK-47 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 30 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 77, stat30 ) 
    stat30 = stat30 + 1 
  if (tonumber(getPedStat( killer, 77 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Ametralladora AK-47", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- Ametralladora M4 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 31 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 78, stat31 ) 
    stat31 = stat31 + 1 
  if (tonumber(getPedStat( killer, 78 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Ametralladora M4", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
----------- Sniper 
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon) 
  if weapon == 34 then 
    givePlayerMoney(killer,10) 
    setPedStat(killer, 80, stat34 ) 
    stat34 = stat34 + 1 
  if (tonumber(getPedStat( killer, 79 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Rifle de Francotirador", killer, 255, 255, 255, true) 
  end 
 end 
end) 
  
  
------------- Seccion que hace que se guarden los stats -------------------------- 
function saveWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local stats = "" 
        for stat=69, 79 do 
            local value = getPedStat(player, stat) 
            stats = stats ..",".. stat ..";".. value 
        end 
        setAccountData(account, "weaponStats", stats) 
    end 
end 
addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) 
  
function loadWeaponStats(player) 
    if (not player or not isElement(player)) then return end 
    local account = getPlayerAccount(player) 
    if (account and not isGuestAccount(account)) then 
        local statsData = getAccountData(account,"weaponStats") 
        local stats = split(statsData, ",") 
        for k, v in ipairs(stats) do 
            local stat = split(v, ";") 
            setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) 
        end 
    end 
end 
addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end) 
  

Edited by Guest
Link to comment

En ves de utilizar variables por qué no usas getPedStat? Te dejo un ejemplo en la primera:

  
addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon)   
  if weapon == 22 then 
    givePlayerMoney(killer,10) 
    setPedStat (killer, 69, getPedStat(killer,69)+1)   
  if (tonumber(getPedStat( killer, 69 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Pistola", killer, 255, 255, 255, true) 
  end    
 end 
end) 
  

Link to comment

Pues no estoy muy seguro, pero he probado con varios argumentos y nada sigue compartiendo los stats con todos, y la verdad no se que poner para que solo le de stats a quien disparo, rayos esto si que es complicado :cry: que otra cosa se podria hacer?

addEvent("onZombieWasted",true) 
addEventHandler("onZombieWasted",root, 
 function (killer, weapon)   
  if weapon == 22 then 
    givePlayerMoney(killer,10) 
    setPedStat (killer, 69, getPedStat(killer,69)+1)   
  if (tonumber(getPedStat( killer, 69 )) == 999) then 
        outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Pistola", killer, 255, 255, 255, true) 
  end   
 end 
end) 

Link to comment

eso no lo he chekado pero casi estoy seguro que le ha de salir a todos, y por ejemplo si yo completo el stat de alguna arma ya no sigue sumando puntos a los stats de nadie en el server, pero si estoy solo yo si funciona bien es decir si alguien llega a los 1000 deja de funcionar el script, o sabes de que otra forma puedo hacer esto? gracias por tu atencion

Link to comment

Si lo estaba probando talcual me diste el ejemplo y funcionaba bien pero te digo aparecia el problema que le daba stats a todos, pero aqui el problema yo solo remplase tu ejemplo por el mio pero no hice lo mismo con los demas con la escuasa de "pues si funciona este bien depues arrglo los demas" y pues asi estube probando solo con el arma del ejemplo que me diste y no funcionaba pasaba lo mismo y ahora que vi tu ultimo mensaje dije pues puede que no trabaje bien por que los demas estan mal y eso afecta a todo, pues arregle todo y que crees funciona al 100% bien, mucha gracias Tomas por ayudarme de verdad te lo agradesco y siento mucho a verte hecho perder tiempo si tan solo lo hubiera colocado bien todo desde el inicio ya hubiese quedado desde cuando. gracias por tu atencion :D

Link to comment
  • Recently Browsing   0 members

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