Jump to content

help with startResource


AE.

Recommended Posts

Posted
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

Posted
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

Posted

 

2 minutes ago, 3laa33 said:

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

 

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

But you need to log in with Console permission too, I think.

Posted
Just now, draobrehtom said:

 

But you need to log in with Console permission too, I think.

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

 

Posted

Well, add this in your resource meta:

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

After execute: aclrequest allow resource_name all

  • Like 1
Posted (edited)
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
Posted
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

Posted

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

Posted (edited)

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

Posted
1 minute ago, 3laa33 said:

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

i did it but whenever i make new account it says 'this is not the first time' ... 

Posted (edited)
2 minutes ago, 3laa33 said:

i did it but whenever i make new account it says 'this is not the first time' ... 

It is because you have already account data on the guest account in database mta.

Edited by draobrehtom
Posted

this is mindfuck ! 

2 minutes ago, draobrehtom said:

It is because you have already account data on the guest account in database mta.

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

Posted
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
)

 

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

Posted
Just now, 3laa33 said:

still don't start the resource .. 
 

Every time if you get error in scripting, you need to tell us, which error are you have or in which statements you are getting this error. Because I even don't know have you a logic error or something else.

Posted

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]
 

Posted (edited)
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
Posted
1 minute ago, John Smith said:

Jesus do you guys even know how to script?

replace


startResource ( skinnew )

with


startResource(getResourceFromName("skinnew"))

 

sorry master of programming 
it's working 

Posted
1 minute ago, John Smith said:

Glad to hear that ^^

there's another thing master ... can i make the resource start for one player .?

well looks like the master don't know ...

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