Jump to content

Help Me i need it :(


^Dev-PoinT^

Recommended Posts

if the Players Spawn give them anti-Damge For 5 Secned and then

outputChatBox(getPlayerName).. is No Not Protected!

did you get it?

Dev_Point.

If you want to cancel damage on a player you need to cancel it clientside. You could do something like:

Server:

  
function setPlayerAlphaProtectedVisible(enabled) 
    if enabled == true then 
        setElementAlpha ( source, 150 ) 
    elseif enabled == false then 
        setElementAlpha ( source, 255 ) 
    end 
end 
  
function setPlayerProtected() 
triggerClientEvent(source,"enableClientPlayerProtection",source,true) 
setPlayerAlphaProtectedVisible(true) 
setTimer(setPlayerAlphaProtectedVisible,5000,1,false) 
end 
addEventHandler("onPlayerSpawn",root,setPlayerProtected) 
  

Client:

  
function cancelDamageOnHurt 
cancelEvent() 
end 
  
function enableClientPlayerProtection(enabled) 
    if enabled == true then 
        addEventHandler("onClientPlayerDamage",localPlayer,cancelDamageOnHurt) 
        setTimer(enableClientPlayerProtection,5000,1,false) 
    elseif enabled == false then 
        removeEventHandler("onClientPlayerDamage",localPlayer,cancelDamageOnHurt) 
        outputChatBox(getPlayerName(localPlayer) .. " is no longer spawnprotected ",0,153,0,true ) 
    end 
end 
addEvent("enableClientPlayerProtection",true) 
addEventHandler("enableClientPlayerProtection",localPlayer,enableClientPlayerProtection) 
  

NOTE: HAVENT TESTED IT!

I expect that this would work, and it would protect the player for 5 secs every time he spawns.

You could add some checks to disable this for some players.

Feel free to use this and develop it further if you can use it.

Edited by Guest
Link to comment

Client Side

local Protect = false 
  
function OnSpawn() 
Protect = true 
setTimer(function() 
Protect = false 
triggerServerEvent("ShowMsg",localPlayer) 
end, 5000, 1) 
end 
addEventHandler("onClientPlayerSpawn",localPlayer,OnSpawn) 
  
function ProtectDamage() 
     if (Protect) then 
          cancelEvent() 
     end 
end 
addEventHandler ("onClientPlayerDamage",localPlayer,ProtectDamage) 

Server Side

function msg() 
outputChatBox(getPlayerName(source).." is No Not Protected!",root,255,255,0,true) 
end 
addEvent("ShowMsg",true) 
addEventHandler ("ShowMsg",root,msg) 

Link to comment

i fix it with this :)

function msg() 
outputChatBox(getPlayerName(source).." is Not Protected!",root,255,0,0,true) 
end 
addEvent("ShowMsg",true) 
addEventHandler ("ShowMsg",root,msg) 
  
function spawn () 
outputChatBox(getPlayerName(source).." is Spawn Protected !",root,0,255,0,true) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), spawn ) 

its Nice to fix by myself :)

Link to comment

I just tested the first script I gave you. There was a few errors in it, but it works.

Server:

  
function setPlayerAlphaProtectedVisible(enabled,source) 
    if enabled == true then 
        setElementAlpha ( source, 150 ) 
    elseif enabled == false then 
        setElementAlpha ( source, 255 ) 
    end 
end 
  
function setPlayerProtected() 
triggerClientEvent(source,"enableClientPlayerProtection",source,true) 
setPlayerAlphaProtectedVisible(true,source) 
setTimer(setPlayerAlphaProtectedVisible,5000,1,false,source) 
end 
addEventHandler("onPlayerSpawn",root,setPlayerProtected) 
  

Client:

  
function cancelDamageOnHurt() 
cancelEvent() 
end 
  
function enableClientPlayerProtection(enabled) 
    if enabled == true then 
        addEventHandler("onClientPlayerDamage",localPlayer,cancelDamageOnHurt) 
        setTimer(enableClientPlayerProtection,5000,1,false) 
    outputChatBox(getPlayerName(localPlayer) .. " is now spawnprotected ",0,153,0,true ) 
    elseif enabled == false then 
        removeEventHandler("onClientPlayerDamage",localPlayer,cancelDamageOnHurt) 
        outputChatBox(getPlayerName(localPlayer) .. " is no longer spawnprotected ",0,153,0,true ) 
    end 
end 
addEvent("enableClientPlayerProtection",true) 
addEventHandler("enableClientPlayerProtection",localPlayer,enableClientPlayerProtection) 
  

This example WILL work.

Try and read it and understand it Dev_Point.

EDIT:

I'm very happy to hear you fixed it on your own! That's what I like to see from you Dev_Point :)

You are getting better and better, so keep it up buddy.

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