Raised This Month: $ Target: $400
 0% 

FakeClientCommand without client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
birno
Senior Member
Join Date: Mar 2010
Old 06-13-2010 , 18:04   FakeClientCommand without client
Reply With Quote #1

How can I use FakeClientCommand without error if no client in game?
For example in a "round_start" hook with "EventHookMode_Pre":
Code:
public Action:RoundStart(Handle:event, String:event_name[], bool:dontBroadcast)
{
	new flags2 = GetCommandFlags("director_stop");
	SetCommandFlags("director_stop", flags2 & ~FCVAR_CHEAT);
	FakeClientCommand(1, "director_stop");
		
	SetCommandFlags("director_stop", flags2|FCVAR_CHEAT);
}
In this case I get an error message:
Code:
[SM] Native "FakeClientCommand" reported: Client index 1 is invalid
What's the correct solution?
birno is offline
recon0
Veteran Member
Join Date: Sep 2007
Location: US
Old 06-13-2010 , 18:36   Re: FakeClientCommand without client
Reply With Quote #2

You should be able to execute it on the server using ServerCommand.
__________________
recon0 is offline
birno
Senior Member
Join Date: Mar 2010
Old 06-14-2010 , 12:00   Re: FakeClientCommand without client
Reply With Quote #3

If I use the ServerCommand says me that I can't use that in multiplayer just if sv_cheats 1 enabled.
If I remove the cheat flag and try that way get the same message so it's not a solution.
birno is offline
BAILOPAN
Join Date: Jan 2004
Old 06-14-2010 , 12:05   Re: FakeClientCommand without client
Reply With Quote #4

So, you want a way to invoke commands instantly?
__________________
egg
BAILOPAN is offline
birno
Senior Member
Join Date: Mar 2010
Old 06-14-2010 , 12:30   Re: FakeClientCommand without client
Reply With Quote #5

Yes, I think.
My english not the best, therefore maybe I'm ambiguous, sorry for that.
I want to run a command before the game start, because I need to spawn clients myself, not by the director.
As I see there's a lot of plugin that want to run commands the same way, for example create a timer that repeat every 1 seconds so if the game load a new map it cant find a valid client and generate a lot of error in the logs.
I think theres a better way to do this but I dont know how.
I hope you understand me.
birno is offline
dirka_dirka
Veteran Member
Join Date: Nov 2009
Old 06-14-2010 , 19:36   Re: FakeClientCommand without client
Reply With Quote #6

if the plugin in yer example is spawning tanks while there are no players, then that plugin shouldnt be running.

try something like:
client = GetAnyClient();

GetAnyClient { for (new i=1; i<=MaxClients; i++) { if (IsClientInGame(i) && !IsFakeClient(i)) return i; } return -1;}

if it returns -1, dont do the command. if it returns anything else (which would be a number between 1 and MaxClients) then use that client number to execute the desired cheat command.
dirka_dirka is offline
birno
Senior Member
Join Date: Mar 2010
Old 06-15-2010 , 11:41   Re: FakeClientCommand without client
Reply With Quote #7

I know this method and it's work fine if I want to use in a function that run when theres a player in the game, but in the first post example it wont work, because the round dont start.
Its not a big problem, im just interested so if theres no a real solution its fine.
birno is offline
BAILOPAN
Join Date: Jan 2004
Old 06-16-2010 , 18:49   Re: FakeClientCommand without client
Reply With Quote #8

File a bug, assuming you want FakeServerCommand(), I think this is something we can implement.
__________________
egg
BAILOPAN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode