Jump to content

Script Dosen't work


Recommended Posts

what's the problem with this script...this script to set all players weapon skills to 0...but when i reconnect my weapon be removed and i have to get a new fine...then when i aim and shot i can do it while moving..so the script removes my weapon every Login and don't set players waepon skills to 0 before i do restart script

    local Aplayers = getAlivePlayers () 
    for index, players in ipairs( Aplayers ) do 
                setPedStat(players, 69, 0) 
                setPedStat(players, 70, 0) 
                setPedStat(players, 71, 0) 
                setPedStat(players, 72, 0) 
                setPedStat(players, 73, 0) 
                setPedStat(players, 74, 0) 
                setPedStat(players, 75, 0) 
                setPedStat(players, 76, 0) 
                setPedStat(players, 77, 0) 
                setPedStat(players, 78, 0) 
                setPedStat(players, 79, 0) 
                
    end 

Link to comment
function WeapStats() 
local Aplayers = getAlivePlayers () 
    for index, players in ipairs( Aplayers ) do 
    setPedStat(players, 69, 0) 
    setPedStat(players, 70, 0) 
    setPedStat(players, 71, 0) 
    setPedStat(players, 72, 0) 
    setPedStat(players, 73, 0) 
    setPedStat(players, 74, 0) 
    setPedStat(players, 75, 0) 
    setPedStat(players, 76, 0) 
    setPedStat(players, 77, 0) 
    setPedStat(players, 78, 0) 
    setPedStat(players, 79, 0) 
    end 
end 
addEventHandler ( "onResourceStart", getRootElement(), WeapStats ) 

Edited by Guest
Link to comment
local stats = { 
    [ 69 ] = 0, 
    [ 70 ] = 0, 
    [ 71 ] = 0, 
    [ 72 ] = 0, 
    [ 73 ] = 0, 
    [ 74 ] = 0, 
    [ 75 ] = 0, 
    [ 76 ] = 0, 
    [ 77 ] = 0, 
    [ 78 ] = 0, 
    [ 79 ] = 0, 
    [ 160 ] = 0, 
    [ 229 ] = 0, 
    [ 230 ] = 0 
} 
  
local function applyStats(player) 
    for stat,value in pairs(stats) do 
        setPedStat(player, stat, value) 
    end 
end 
  
addEventHandler('onResourceStart', resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType('player')) do 
            applyStats(player) 
        end 
    end 
) 
  
addEventHandler('onPlayerJoin', root, 
    function() 
        applyStats(source) 
    end 
) 
  
addEventHandler('onGamemodeMapStart', root, 
    function() 
        for _,player in ipairs(getElementsByType('player')) do 
            applyStats(player) 
        end  
    end 
) 
  
addEventHandler('onPlayerSpawn', root, 
    function() 
        applyStats(source) 
    end 
) 
  

Link to comment
local stats = { 
    [ 69 ] = 0, 
    [ 70 ] = 0, 
    [ 71 ] = 0, 
    [ 72 ] = 0, 
    [ 73 ] = 0, 
    [ 74 ] = 0, 
    [ 75 ] = 0, 
    [ 76 ] = 0, 
    [ 77 ] = 0, 
    [ 78 ] = 0, 
    [ 79 ] = 0, 
    [ 160 ] = 0, 
    [ 229 ] = 0, 
    [ 230 ] = 0 
} 
  
local function applyStats(player) 
    for stat,value in pairs(stats) do 
        setPedStat(player, stat, value) 
    end 
end 
  
addEventHandler('onResourceStart', resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType('player')) do 
            applyStats(player) 
        end 
    end 
) 
  
addEventHandler('onPlayerJoin', root, 
    function() 
        applyStats(source) 
    end 
) 
  
addEventHandler('onGamemodeMapStart', root, 
    function() 
        for _,player in ipairs(getElementsByType('player')) do 
            applyStats(player) 
        end  
    end 
) 
  
addEventHandler('onPlayerSpawn', root, 
    function() 
        applyStats(source) 
    end 
) 
  

Thanks a lot..but this will save all players stats ?..also i need it onPlayerLogin :) not onPlayerJoin..and onPlayerWasted Too :) And Thanks a lot!!!

Link to comment

Try this it should work perfectly

addEventHandler ("onPlayerLogin",root, 
function() 
loadPedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerQuit",root, 
function() 
savePedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerLogout",root, 
function(thePreviousAccount) 
savePedStats( thePreviousAccount ) 
end 
) 
function savePedStats( Acc) 
local pedposx,pedposy,pedposz = getElementPosition( source ) 
local pedrotx,pedroty,pedrotz = getElementRotation( source ) 
setAccountData(Acc, "pos.x", pedposx) 
setAccountData(Acc, "pos.y", pedposy) 
setAccountData(Acc, "pos.z", pedposz) 
setAccountData(Acc, "rot.x", pedrotx) 
setAccountData(Acc, "rot.y", pedroty) 
setAccountData(Acc, "rot.z", pedrotz) 
setAccountData(Acc, "skin", getPedSkin( source )) 
setAccountData(Acc, "armor", getPedArmor( source )) 
setAccountData(Acc, "health", getElementHealth( source )) 
setAccountData(Acc, "money",getPlayerMoney( source )) 
for i = 21 , 25 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
for i = 69 , 79 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
end 
function loadPedStats(Acc ) 
setElementPosition(source,getAccountData(Acc, "pos.x"),getAccountData(Acc, "pos.y"),getAccountData(Acc, "pos.z")) 
setElementRotation(source,getAccountData(Acc, "rot.x"),getAccountData(Acc, "rot.y"),getAccountData(Acc, "rot.z")) 
setPedSkin(source,getAccountData(Acc, "skin")) 
setPedArmor(source,getAccountData(Acc, "armor")) 
setElementHealth(source,getAccountData(Acc, "health")) 
setPlayerMoney(source,getAccountData(Acc, "money")) 
for i = 21 , 25 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
for i = 69 , 79 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
end 

Link to comment
Try this it should work perfectly
addEventHandler ("onPlayerLogin",root, 
function() 
loadPedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerQuit",root, 
function() 
savePedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerLogout",root, 
function(thePreviousAccount) 
savePedStats( thePreviousAccount ) 
end 
) 
function savePedStats( Acc) 
local pedposx,pedposy,pedposz = getElementPosition( source ) 
local pedrotx,pedroty,pedrotz = getElementRotation( source ) 
setAccountData(Acc, "pos.x", pedposx) 
setAccountData(Acc, "pos.y", pedposy) 
setAccountData(Acc, "pos.z", pedposz) 
setAccountData(Acc, "rot.x", pedrotx) 
setAccountData(Acc, "rot.y", pedroty) 
setAccountData(Acc, "rot.z", pedrotz) 
setAccountData(Acc, "skin", getPedSkin( source )) 
setAccountData(Acc, "armor", getPedArmor( source )) 
setAccountData(Acc, "health", getElementHealth( source )) 
setAccountData(Acc, "money",getPlayerMoney( source )) 
for i = 21 , 25 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
for i = 69 , 79 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
end 
function loadPedStats(Acc ) 
setElementPosition(source,getAccountData(Acc, "pos.x"),getAccountData(Acc, "pos.y"),getAccountData(Acc, "pos.z")) 
setElementRotation(source,getAccountData(Acc, "rot.x"),getAccountData(Acc, "rot.y"),getAccountData(Acc, "rot.z")) 
setPedSkin(source,getAccountData(Acc, "skin")) 
setPedArmor(source,getAccountData(Acc, "armor")) 
setElementHealth(source,getAccountData(Acc, "health")) 
setPlayerMoney(source,getAccountData(Acc, "money")) 
for i = 21 , 25 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
for i = 69 , 79 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
end 

Sure man..and i don't know how i can thank you for this nice help :)

Link to comment
Try this it should work perfectly
addEventHandler ("onPlayerLogin",root, 
function() 
loadPedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerQuit",root, 
function() 
savePedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerLogout",root, 
function(thePreviousAccount) 
savePedStats( thePreviousAccount ) 
end 
) 
function savePedStats( Acc) 
local pedposx,pedposy,pedposz = getElementPosition( source ) 
local pedrotx,pedroty,pedrotz = getElementRotation( source ) 
setAccountData(Acc, "pos.x", pedposx) 
setAccountData(Acc, "pos.y", pedposy) 
setAccountData(Acc, "pos.z", pedposz) 
setAccountData(Acc, "rot.x", pedrotx) 
setAccountData(Acc, "rot.y", pedroty) 
setAccountData(Acc, "rot.z", pedrotz) 
setAccountData(Acc, "skin", getPedSkin( source )) 
setAccountData(Acc, "armor", getPedArmor( source )) 
setAccountData(Acc, "health", getElementHealth( source )) 
setAccountData(Acc, "money",getPlayerMoney( source )) 
for i = 21 , 25 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
for i = 69 , 79 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
end 
function loadPedStats(Acc ) 
setElementPosition(source,getAccountData(Acc, "pos.x"),getAccountData(Acc, "pos.y"),getAccountData(Acc, "pos.z")) 
setElementRotation(source,getAccountData(Acc, "rot.x"),getAccountData(Acc, "rot.y"),getAccountData(Acc, "rot.z")) 
setPedSkin(source,getAccountData(Acc, "skin")) 
setPedArmor(source,getAccountData(Acc, "armor")) 
setElementHealth(source,getAccountData(Acc, "health")) 
setPlayerMoney(source,getAccountData(Acc, "money")) 
for i = 21 , 25 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
for i = 69 , 79 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
end 

Sure man..and i don't know how i can thank you for this nice help :)

But this will just set 8 weapon skills as 0? or what? :) i don't see weapon skills here bro..just save everything :D

Link to comment
Try this it should work perfectly
addEventHandler ("onPlayerLogin",root, 
function() 
loadPedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerQuit",root, 
function() 
savePedStats(  getPlayerAccount(source)) 
end 
) 
addEventHandler ("onPlayerLogout",root, 
function(thePreviousAccount) 
savePedStats( thePreviousAccount ) 
end 
) 
function savePedStats( Acc) 
local pedposx,pedposy,pedposz = getElementPosition( source ) 
local pedrotx,pedroty,pedrotz = getElementRotation( source ) 
setAccountData(Acc, "pos.x", pedposx) 
setAccountData(Acc, "pos.y", pedposy) 
setAccountData(Acc, "pos.z", pedposz) 
setAccountData(Acc, "rot.x", pedrotx) 
setAccountData(Acc, "rot.y", pedroty) 
setAccountData(Acc, "rot.z", pedrotz) 
setAccountData(Acc, "skin", getPedSkin( source )) 
setAccountData(Acc, "armor", getPedArmor( source )) 
setAccountData(Acc, "health", getElementHealth( source )) 
setAccountData(Acc, "money",getPlayerMoney( source )) 
for i = 21 , 25 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
for i = 69 , 79 do 
setAccountData(Acc, "stat."..i , getPedStat(source,i)) 
end 
end 
function loadPedStats(Acc ) 
setElementPosition(source,getAccountData(Acc, "pos.x"),getAccountData(Acc, "pos.y"),getAccountData(Acc, "pos.z")) 
setElementRotation(source,getAccountData(Acc, "rot.x"),getAccountData(Acc, "rot.y"),getAccountData(Acc, "rot.z")) 
setPedSkin(source,getAccountData(Acc, "skin")) 
setPedArmor(source,getAccountData(Acc, "armor")) 
setElementHealth(source,getAccountData(Acc, "health")) 
setPlayerMoney(source,getAccountData(Acc, "money")) 
for i = 21 , 25 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
for i = 69 , 79 do 
setPedStat(source,i,getAccountData(Acc, "stat."..i)) 
end 
end 

Sure man..and i don't know how i can thank you for this nice help :)

But this will just set 8 weapon skills as 0? or what? :) i don't see weapon skills here bro..just save everything :D

and i got a problem with this script when i starts it

ERROR:

SCRIPT ERROR: Gate1\Weapon.lua:1: unexpected symbo1 near'>'....Warning: Loading Script Failed: Gate1\weapon.lua:1: unexpected 

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