Jump to content

help with startResource


AE.

Recommended Posts

addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "FirstTime") then 
        outputChatBox("You're playing for the first time!", source, 0, 255, 0)
        startResource ( skinnew )		
		setElementPosition ( source, 1254.50049, -790.40015, 92.03018 )
        setAccountData(account, "FirstTime", true) 
    else 
        outputChatBox("This is not the first time for you!", source, 255, 0, 0) 
    end 
end) 


it do every thing right and working but the resource won't start and i added the script on admin group in the acl .. still don't work

Link to comment
3 minutes ago, aka Blue said:

¿Why you need to start a resource every time that a player has logged in? O.o 

it's just if the player logged in for the first time

 

1 minute ago, draobrehtom said:

For a starting resource from another resource, you need to set a permission for you resource "startResource" "true" in acl.xml.

i already add the script in console  so .. i'am sure that console can startResource

Link to comment
4 minutes ago, 3laa33 said:

why the fuck? then i have to give every player login in server console?

 

It's for a security reason and more easily structure of acl (grouping rights and types of the rights, you need to read about it on the Wiki - acl.xml article).

Edited by draobrehtom
Link to comment
4 minutes ago, aka Blue said:

Well, add this in your resource meta:


	<aclrequest>
		<right name="function.startResource" access="true" />
	</aclrequest>

After execute: aclrequest allow resource_name all

didn't work

bad argument @ 'startResource' [Expected resource-data at argument 1, got nil]

maybe this help

Link to comment

Try this:

addEventHandler( "onPlayerLogin", root,
	function(  )
		local account = getPlayerAccount( source )
		if ( account ) then
			if ( not isGuestAccount( account ) ) then
				if ( getAccountData( account, "FirstTime" ) ) then
					outputChatBox("You're playing for the first time!", source, 0, 255, 0)
					startResource ( skinnew )		
					setElementPosition ( source, 1254.50049, -790.40015, 92.03018 )
					setAccountData(account, "FirstTime", true) 				
				else
					outputChatBox("This is not the first time for you!", source, 255, 0, 0) 
				end
			end
		end
	end
)

And do what i post, cleaning the acl.xml

Link to comment

Test this example with added aclrequest to meta.xml and give us results, please:

function startTheResource ( thePlayer, command, resourceName )
	if ( resourceName ) then -- Check if they specified a resource name
		local resource = getResourceFromName ( resourceName ) -- Get the resource
 
		local start = startResource ( resource ) -- Start the resource
		if ( start ) then -- If it was successfully started...
			outputChatBox ( resourceName .. " was started successfully.", thePlayer, 255, 0, 0 )
		else -- If it wasn't successfully started...
			outputChatBox ( "This resource doesn't exist.", thePlayer, 255, 0, 0 )
		end
	else -- If they didn't put a resource name...
		outputChatBox ( "Please specify a resource to start.", thePlayer, 255, 0, 0 )
	end
end
addCommandHandler ( "resource-start", startTheResource ) -- Make it trigger when somebody types "/resource-start"

 

Edited by draobrehtom
Link to comment
2 minutes ago, aka Blue said:

Try this:


addEventHandler( "onPlayerLogin", root,
	function(  )
		local account = getPlayerAccount( source )
		if ( account ) then
			if ( not isGuestAccount( account ) ) then
				if ( getAccountData( account, "FirstTime" ) ) then
					outputChatBox("You're playing for the first time!", source, 0, 255, 0)
					startResource ( skinnew )		
					setElementPosition ( source, 1254.50049, -790.40015, 92.03018 )
					setAccountData(account, "FirstTime", true) 				
				else
					outputChatBox("This is not the first time for you!", source, 255, 0, 0) 
				end
			end
		end
	end
)

And do what i post, cleaning the acl.xml

i didn't get it, cleaning the acl ? why 

Link to comment
3 minutes ago, 3laa33 said:

this is mindfuck ! 

so how i make sure it work for the new players >>??

I'm sorry for this, I was wrong:
`

Quote

]Data stored in a guest account is not stored after the player has left the server. As a consequence, this function will check if a player is logged in or not.

Try this, It was edited:
 

addEventHandler( "onPlayerLogin", root,
	function(  )
		local account = getPlayerAccount( source )
		if ( account ) then
			if ( not isGuestAccount( account ) ) then
				if ( not getAccountData( account, "FirstTime" ) ) then
					outputChatBox("You're playing for the first time!", source, 0, 255, 0)
					startResource ( skinnew )		
					setElementPosition ( source, 1254.50049, -790.40015, 92.03018 )
					setAccountData(account, "FirstTime", true) 				
				else
					outputChatBox("This is not the first time for you!", source, 255, 0, 0) 
				end
			end
		end
	end
)

 

Link to comment
7 minutes ago, draobrehtom said:

I'm sorry for this, I was wrong:
`

Try this, It was edited:
 


addEventHandler( "onPlayerLogin", root,
	function(  )
		local account = getPlayerAccount( source )
		if ( account ) then
			if ( not isGuestAccount( account ) ) then
				if ( not getAccountData( account, "FirstTime" ) ) then
					outputChatBox("You're playing for the first time!", source, 0, 255, 0)
					startResource ( skinnew )		
					setElementPosition ( source, 1254.50049, -790.40015, 92.03018 )
					setAccountData(account, "FirstTime", true) 				
				else
					outputChatBox("This is not the first time for you!", source, 255, 0, 0) 
				end
			end
		end
	end
)

 

still don't start the resource .. 
 

Link to comment
2 minutes ago, 3laa33 said:

it warp me and it do every thing  but still the resource = "skinnew" don't start this replace skin 23 with anthor skin

and i'am still getting debug
bad argument @ 'startResource'  [Expected resource-data at argument 1, got nil]
 

Can you post all code with the part getResourceFromName and also give a names of your two resources? Maybe it's a typo error, you know.

Edited by draobrehtom
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...