Jump to content

[HELP] Get player name when starting resource


-Note

Recommended Posts

Posted

Is it possible to get the player name who restart/start/stop a specific resource?

 

Cuz I'm using this to catch player name but It returns me some error which is "getPlayerName expected player, got nil" but I already added a player.

Sorry if I have done something wrong and this is my first time in Lua.

addEventHandler("onResourceStart",root,
	function (resource, thePlayer)
		if getResourceInfo(resource,"type") ~= "map" then
			outputChatBox(getResourceName(resource).." started by "..getPlayerName(thePlayer))
		end
	end
)

 

  • Moderators
Posted (edited)

Hi!

Sadly you can't catch player's element like that. thePlayer is not a "magic" variable, event's argument list is predetermined, you can find it on wiki.

Here you can see, this event is pass only one variable, at first place.

Quote

Parameters


resource startedResource
  • startedResource: the resource that was started.

 

You need to do an own restart function/command, with: addCommandHandler and restartResource
And print your own notification when someone use this command.

Edited by Patrick

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