Jump to content

making a script for a "Group" only


Recommended Posts

Hello guys i will try to go straight to the point :) 

this is a health regeneration over time script

(this is not mine , full credit goes to the maker)  

setTimer(
    function ()
        setElementHealth ( localPlayer, ( getElementHealth ( localPlayer ) + 15 ) )
    end,5000,0)
function autor()
outputChatBox("health regen", source, 0, 255, 255, true)
end
addEventHandler("onClientPlayerJoin", getRootElement(), autor)

i want this lua cript to be operational for "VIP" group (for example) only . 

means , only players with VIP can have their health regenerated . 

what should i add to make it that way ? thank you . 

 

these are some things i tried for myself . (but didn't work)

in acl.xml under group VIP  

<object name="resource.healthregeneration"></object>

under acl VIP 

access="true"></right>
        <right name="resource.healthregeneration"

under all Acls

access="false"></right>
        <right name="resource.healthregeneration"

 

Link to comment
function regen()
	for i,v in pairs(getElementsByType("player")) do
		if isObjectInACLGroup( "user."..getPlayerName(v), aclGetGroup("VIP")) then
			setElementHealth (v, getElementHealth (v) + 15)
		end
	end
end
setTimer(regen, 5000, 0)

function Join()
	outputChatBox("health regen", source, 0, 255, 255, true)
end
addEventHandler("onClientPlayerJoin", getRootElement(), Join)

didn't test it 

use it server side not client

Edited by kikos500
Link to comment
  1. function healthRegen()
  2. for i,v in pairs(getElementsByType("player")) do
  3. if isObjectInACLGroup( "user."..getAccountName(getPlayerAccount(v)), aclGetGroup("VIP")) then
  4. setElementHealth (v, getElementHealth (v) + 15)
  5. end
  6. end
  7. end
  8. setTimer(healthRegen, 5000, 0)
  9.  
  10. function clientJoin()
  11. outputChatBox("health regen", source, 0, 255, 255, true)
  12. end
  13. addEventHandler("onClientPlayerJoin", getRootElement(), clientJoin)
Edited by N98E
Link to comment

This code works,

function Loin()
	if isObjectInACLGroup( "user."..getAccountName(getPlayerAccount(source)), aclGetGroup("VIP") ) then
		setTimer( regen, 50, 0, source )
		outputChatBox("Health regen", source, 0, 255, 255, true)
	end
end
addEventHandler("onPlayerLogin", getRootElement(), Loin)

function regen( player )
	setElementHealth ( player, getElementHealth ( player ) + 15 )
end

 

Link to comment

none of them works .. 

im sure they are right , but i think something is missing in the resource file ? 

this is my meta file , is something wrong in it ? 

<meta>
	<info author="TimmY14" version="1.0.0" type="script" name="healthregeneration" description="hp regen"  />
	<script src="health.lua" type="server" />
</meta>

 

Link to comment
1 hour ago, Zie[E]D_)"U.R said:

none of them works .. 

im sure they are right , but i think something is missing in the resource file ? 

this is my meta file , is something wrong in it ? 


<meta>
	<info author="TimmY14" version="1.0.0" type="script" name="healthregeneration" description="hp regen"  />
	<script src="health.lua" type="server" />
</meta>

 

All looks fine. You sure the group is "VIP" and not "ViP" or something?

Link to comment

everything looks fine ! maybe the scripts are wrong (remember , it is a vip only resource and +15 health every 5 seconds) 

this is what i have done so far :

 acl.xml 

<group name="VIP">
        <acl name="VIP"></acl>
        <object name="user.ziedur"></object>

health.lua ( i tried Rose , N98E and kokos500 with the fixed getplayerName ) 

For Rose's script when i logged in with my VIP accounts i got the output health regen in my chat box but no health is generated

for kokos500 : 

I1K11dzHTCiq5CRc65TfiA.png

meta.xml 

<meta>
	<info author="TimmY14" version="1.0.0" type="script" name="healthregeneration" description="hp regen"  />
	<script src="health.lua" type="server" />
</meta>

 

Edited by Zie[E]D_)"U.R
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...