testuser4353

How to user OpenScriptMenu to send commands to server

Recommended Posts

Hello,

I'm new to cod scripting, but im trying my best,

I have created scripts that i can activate from chat $mycommand and it works as expected, now chat has a spam filter if u use that command as a bind and press it to many times in short period. Im doing that with addscriptcommand()

So im searching for a workaround how to execute script on server that's not going over chat? 

I saw some people using openscriptmenu <menu_name> <fun_name> but i can't find documentation for it how to implement it?

Any help and advice on how to fix this is apreciated and welcome :)

Share this post


Link to post
Share on other sites
Posted (edited)

COD4 menus can send messages to gsc using scriptMenuResponse

scriptMenuResponse "hello"

and these can be captured in gsc by waiting for a menu response

self waittill( "menuresponse", menu, cmd );

But you can emulate this by using console command openscriptmenu to send a message to be picked up in your gsc. For example I use this as a way to quickly test scripts

getCmd()
{
	self endon( "disconnect" );
    while( 1 )
	{
		self waittill( "menuresponse", menu, cmd );
		token = strTok(cmd, ":");
		if(token[0] == "menu"){
            if(isDefined(token[1])){
                self openMenuFile(token[1]); 
            }
        }	
        if(token[0] == "hudtest"){
            self thread hudTest();
        }				
    }
}

So if in console I type openscriptmenu -1 hudtest, it will run my hudtest function (I use -1 for menu name as i know there is no menu with that name)

Edited by sheep_wizard2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.