Jump to content

Clientside not working


Recommended Posts

So i just wanted to test things clientside and was trying to make some basic scripts, and this doesn't wanna run. I can't see why. Any suggestions?

regen2 = {} 
hp2 = {} 
  
  
  
function sethp2(amount) 
setElementHealth(localPlayer, amount) 
hp2[localPlayer] = amount 
outputChatBox("sethp "..tostring(amount)) 
end 
  
addEventHandler("onClientPlayerWasted", root, function(killer, weapon, bodypart) 
if localPlayer == source then 
playSound("sounds/wasted.mp3") 
else if localPlayer == killer then 
playSound("sounds/kill.mp3") 
end 
end) 
  
function regen() 
    if hp2[localPlayer] < 99 then 
        sethp2(hp2[localPlayer]+1) 
        if regen2[localPlayer] == true then 
            setTimer(regen, 250, 1) 
        end 
    else 
        sethp2(100) 
        regen2[localPlayer] = false 
    end 
end 
  
  
addEventHandler("onClientResourceStart", root, function() 
  
for i, v in ipairs(getElementsByType("object")) do 
    engineSetModelLODDistance(getElementModel(v), 170) 
end 
end) 
  
  
addEventHandler("onClientPlayerSpawn", localPlayer, function() 
sethp2(100) 
regen2[localPlayer] = false 
end) 
  
addEventHandler("onClientPlayerWeaponFire", localPlayer, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) 
outputChatBox("hit: "..hitX..", "..hitY..", "..hitZ) 
outputChatBox(getDistanceBetweenPoints3D(hitX, hitY, hitZ, startX, startY, startZ).." meters.") 
outputChatBox(" ") 
end) 
  
addEventHandler("onClientPlayerDamage", localPlayer, function(attacker, weapon, bodypart, loss) 
hp2[localPlayer] = hp2[localPlayer]-loss 
if regen2[localPlayer] == false then 
regen2[localPlayer] = true 
regen() 
end 
end) 
  
addEventHandler("onClientPlayerQuit", localPlayer, function() 
regen2[localPlayer] = nil 
hp2[localPlayer] = nil 
end) 
  
  
  

Link to comment
So i just wanted to test things clientside and was trying to make some basic scripts, and this doesn't wanna run. I can't see why. Any suggestions?
regen2 = {} 
hp2 = {} 
  
  
  
function sethp2(amount) 
setElementHealth(localPlayer, amount) 
hp2[localPlayer] = amount 
outputChatBox("sethp "..tostring(amount)) 
end 
  
addEventHandler("onClientPlayerWasted", root, function(killer, weapon, bodypart) 
if localPlayer == source then 
playSound("sounds/wasted.mp3") 
else if localPlayer == killer then 
playSound("sounds/kill.mp3") 
end 
end) 
  
function regen() 
    if hp2[localPlayer] < 99 then 
        sethp2(hp2[localPlayer]+1) 
        if regen2[localPlayer] == true then 
            setTimer(regen, 250, 1) 
        end 
    else 
        sethp2(100) 
        regen2[localPlayer] = false 
    end 
end 
  
  
addEventHandler("onClientResourceStart", root, function() 
  
for i, v in ipairs(getElementsByType("object")) do 
    engineSetModelLODDistance(getElementModel(v), 170) 
end 
end) 
  
  
addEventHandler("onClientPlayerSpawn", localPlayer, function() 
sethp2(100) 
regen2[localPlayer] = false 
end) 
  
addEventHandler("onClientPlayerWeaponFire", localPlayer, function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) 
outputChatBox("hit: "..hitX..", "..hitY..", "..hitZ) 
outputChatBox(getDistanceBetweenPoints3D(hitX, hitY, hitZ, startX, startY, startZ).." meters.") 
outputChatBox(" ") 
end) 
  
addEventHandler("onClientPlayerDamage", localPlayer, function(attacker, weapon, bodypart, loss) 
hp2[localPlayer] = hp2[localPlayer]-loss 
if regen2[localPlayer] == false then 
regen2[localPlayer] = true 
regen() 
end 
end) 
  
addEventHandler("onClientPlayerQuit", localPlayer, function() 
regen2[localPlayer] = nil 
hp2[localPlayer] = nil 
end) 
  
  
  

/debugscript 3 first please.

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