Jump to content

Recommended Posts

Greetings and happy new year all,

I've been working on a script to detect a players ucid and print to screen in game, simple enough I thought...

Doing this only to enable greater functions, gotta start somewhere.

 

Below is a snippet of my code in a main function that is always running in the background
 

-- If Flag # triggered do...
	if trigger.misc.getUserFlag('3002') == 1 then
		
		trigger.action.setUserFlag('3002', false)
		--trigger.action.outText("Success!", 10)
		trigger.action.outSound("1-success.wav")

		txt1 = " Your UCID is..."
		trigger.action.outText(txt1, 10)

		-- does not work starting here...
		id = net.get_player_info(playerID, 'ucid')
		trigger.action.outText(id, 10)
		
	end

 

It will print the "Your UCID is..." part but neve the actual ucid. Feeling I am missing something here? Any feedback or help would be appreciated!

DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB]

Link to post
Share on other sites
11 hours ago, ataribaby said:

I think you can't access net. stuff in mission lua. I am sure it fails at line with net.get_player_info call.

 

Hmm, that would make sense as to why this does not work. Is there any way to check a player UCID with a singleton script?

Or perhaps a way to call it from a mod like SLMOD?

DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB]

Link to post
Share on other sites

Raptor6872, one thing I see in your script is that you use "playerID" in your line :

13 hours ago, Raptor6872 said:

id = net.get_player_info(playerID, 'ucid')

But playerID is just a word if not feed before with something like playerID = Group.getID(Group.getByName('PlayerGroupName'))

or playerID = Unit.getID(Unit.getByName('PlayerUnitName'))

(with 'PlayerGroupName' or 'PlayerUnitName' being the group or unit name of player's aircraft in mission editor)

In this case "playerID" will be a number returned by Group.getID or Unit.getID that will be suitable for the net.get_player_info function

 

BTW I have zero knowledge about server scripts - just something I've noticed.

Link to post
Share on other sites
On 1/6/2021 at 3:51 AM, Raptor6872 said:


 



-- If Flag # triggered do...
	if trigger.misc.getUserFlag('3002') == 1 then
		
		trigger.action.setUserFlag('3002', false)
		--trigger.action.outText("Success!", 10)
		trigger.action.outSound("1-success.wav")

		txt1 = " Your UCID is..."
		trigger.action.outText(txt1, 10)

		-- does not work starting here...
		id = net.get_player_info(playerID, 'ucid')
		trigger.action.outText(id, 10)
		
	end

 

It will print the "Your UCID is..." part but neve the actual ucid. Feeling I am missing something here? Any feedback or help would be appreciated!

 

I'd need to see the full function to give you a better answer, since I don't know where you're getting playerID from (a server event handler, maybe?). 

 

Looks like you specified the optional attribute "ucid" via valid string, so net.get_player_info should return that value only, instead of the whole table...

 

Have you verified that the returned value is indeed a string/number and not the whole table, a nil value or something else?  

 

(It never hurts to use tostring() in cases like this, just to make sure that whatever comes out will be a string) 

 

You could also try not providing the optional attribute and trying to navigate the returned table directly, see what the field ucid contains (if anything). 

 

 

A possible problem that I see in your script is that you used id as a variable name, which I seem to recall is a big no-no (likely to cause conflicts).  

 

I'd avoid using scripting keywords as variable names (like  id, initiator, target, weapon, unit, group, object, time, type, vec2, vec3, point, zone, etc.)

 

Try naming that variable iD instead.

 

 

Right now nothing else comes to mind... the last time I wrote stuff for server environment I had to use net.dostring_in  to get flag values from the mission environment (it was the only thing I could get from there, and it was the only way to get it)... things might've changed since then, which would explain why you were able to retrieve flag values at all with that script. 


Edited by Hardcard
Link to post
Share on other sites

Thanks all for the ideas but I think I've figured out that one cannot simply run NET commands unless it is server side with a dedicated script.

I'm doing a sort of workaround by using the SimpleSlotBlocking Mod by Circibob. Then trying to implement specific F10 commands to those blocked off group slots in this other post (https://forums.eagle.ru/topic/258583-lua-f10-menu-script-questions/?tab=comments#comment-4535725). 

Hopefully this will work out.

 

DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB]

Link to post
Share on other sites
8 hours ago, Raptor6872 said:

 I think I've figured out that one cannot simply run NET commands unless it is server side with a dedicated script.

 

 

Oh, ofc, I assumed you were running the script on a dedicated server, net commands are for server environment only. 

 

Why do you need the ucids, exactly? There might be other ways of achieving your goal.

 

Link to post
Share on other sites
12 hours ago, Hardcard said:

 

Oh, ofc, I assumed you were running the script on a dedicated server, net commands are for server environment only. 

 

Why do you need the ucids, exactly? There might be other ways of achieving your goal.

 


The main goal was to make a "concept" script to pull ucids. Mainly to develop a "admin menu" so I could create different commands that only an authorized user could run.

Was going to use the ucid as a "check" mechanism, as I'd only allow certain ucids to run certain commands.

Now I've moved in to this by using circibobs SSB script with a combination of Group specific, custom F10 commands. Though it is proving more difficult than I'd thought... 

DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB]

Link to post
Share on other sites

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