Jump to content

[Problem] thePlayer


Z4Zy

Recommended Posts

Hi Again....^_^

        in client side of the LUA script, we could done like below,

local player = getLocalPlayer ()

then the word player is equal to the "local player's" specifications.

But in server side....  it couldn't done, because

getLocalPlayer ()

 is a client side event. So what is the way of enter it in to the server side ?? :/

Link to comment

You can't. It is possible in client side, because every client side script runs separately om every players PC. The server side script runs only on the server PC and affects everyone. 

When you trigger a server side event, from client side, you get the client in the variable name "client". It's like source at events

Link to comment

 

in every 2 seconds, admin's health should decrease by 5%. Can you fix below wrong code :/:/:/

 

function decrease ( )
 local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
    for _,p in pairs(getElementsByType ( "player" )) do 
		if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
			setElementHealth ( thePlayer, getElementHealth(thePlayer) - 5 )
        end
    end
end

setTimer ( decrease, 2000, 0 )

 

Link to comment
  • Moderators
1 hour ago, DeadthStrock said:

 

in every 2 seconds, admin's health should decrease by 5%. Can you fix below wrong code :/:/:/

 


function decrease ( )
 local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
    for _,p in pairs(getElementsByType ( "player" )) do 
		if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
			setElementHealth ( thePlayer, getElementHealth(thePlayer) - 5 )
        end
    end
end

setTimer ( decrease, 2000, 0 )

 

function decrease()
    for _, thePlayer in ipairs(getElementsByType("player" )) do 
 		local accName = getAccountName(getPlayerAccount(thePlayer))
		if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then
			setElementHealth(thePlayer, getElementHealth(thePlayer) - 5)
        end
    end
end
setTimer(decrease, 2000, 0)

 

  • Thanks 1
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...