Raised This Month: $51 Target: $400
 12% 

how to pause plugin until one function returns value?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marih
Junior Member
Join Date: Aug 2013
Old 02-27-2015 , 06:42   how to pause plugin until one function returns value?
Reply With Quote #1

Code:
AddCommandListener(Command_PlayerSay, "say");
	//AddCommandListener(Command_PlayerSay, "say_team");
	AddUnusualEffect(iClient, ClientSteamID[ClientControl[iClient]], ClientItems[iClient], Quality[iClient], StringToInt(Effect), ClientIndex[iClient]);
i thought the plugin listen to Command_Playersay until it returns the value. (The plugin doesn't run next line just wait for the return.)

but when it excuted, it seems that plugin listen to command_playersay but don't wait for the return. just run the nextline)

sorry for my bad english. what am i gonna do
marih is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 02-27-2015 , 07:39   Re: how to pause plugin until one function returns value?
Reply With Quote #2

i donk know about what u speaking... but here is maybe something usefull.
PHP Code:
public OnPluginStart()
{
    
AddCommandListener(ListenerSAYCMD);
    
AddCommandListener(ListenerSAYCMD2);
}

public 
Action:Listener(client, const String:command[], argc)
{
    
AddUnusualEffect(...);

from GameVoting.
__________________
neatek is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-27-2015 , 07:53   Re: how to pause plugin until one function returns value?
Reply With Quote #3

Quote:
Originally Posted by neatek View Post
i donk know about what u speaking... but here is maybe something usefull.
PHP Code:
public OnPluginStart()
{
    
AddCommandListener(ListenerSAYCMD);
    
AddCommandListener(ListenerSAYCMD2);
}

public 
Action:Listener(client, const String:command[], argc)
{
    
AddUnusualEffect(...);

from GameVoting.
here is the Command

PHP Code:
public Action:Command_PlayerSay(iClient, const String:command[], argc)
{
    new 
String:arg1[5];
    
GetCmdArg(1arg1sizeof(arg1));
    
ClientIndex[iClient] = StringToInt(arg1)
    return 
Plugin_Handled;

this gets what client says in chat and save into ClientIndex[iClient] as Int.

i wanna make pause the plugin until the command gets client chat.

if saved, then resume

Last edited by marih; 02-27-2015 at 07:54.
marih is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 02-27-2015 , 08:04   Re: how to pause plugin until one function returns value?
Reply With Quote #4

PHP Code:
public Action:Command_PlayerSay(iClient, const String:command[], argc

    new 
String:arg1[5]; 
    
GetCmdArg(1arg1sizeof(arg1)); 
    
ClientIndex[iClient] = StringToInt(arg1
   
    
// you got what u want, if you dont get Int -> StringToInt(arg1), its return 0.
    
AddUnusualEffect(...);

    return 
Plugin_Handled

OR
PHP Code:
public Action:Command_PlayerSay(iClient, const String:command[], argc

    new 
String:arg1[5]; 
    
GetCmdArg(1arg1sizeof(arg1)); 
    
ClientIndex[iClient] = StringToInt(arg1); // if its not Int, ClientIndex[iClient] = 0;
    
return Plugin_Handled
}

public 
YourFunc() {
    
// i think that you want get client index, so 0 index its not valid, its console.
    // here is your pause, if we have 0, we havent data.
    
if(ClientIndex[iClient] > 0
        
AddUnusualEffect(...)

I do not approve of what it written... but
Whats problem?

Anyway, learn new syntax.
__________________

Last edited by neatek; 02-27-2015 at 08:11.
neatek is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-27-2015 , 08:15   Re: how to pause plugin until one function returns value?
Reply With Quote #5

Quote:
Originally Posted by neatek View Post
PHP Code:
public Action:Command_PlayerSay(iClient, const String:command[], argc

    new 
String:arg1[5]; 
    
GetCmdArg(1arg1sizeof(arg1)); 
    
ClientIndex[iClient] = StringToInt(arg1
   
    
// you got what u want, if you dont get Int -> StringToInt(arg1), its return 0.
    
AddUnusualEffect(...);

    return 
Plugin_Handled

OR
PHP Code:
public Action:Command_PlayerSay(iClient, const String:command[], argc

    new 
String:arg1[5]; 
    
GetCmdArg(1arg1sizeof(arg1)); 
    
ClientIndex[iClient] = StringToInt(arg1); // if its not Int, ClientIndex[iClient] = 0;
    
return Plugin_Handled
}

public 
YourFunc() {
    
// i think that you want get client index, so 0 index its not valid, its console.
    // here is your pause, if we have 0, we havent data.
    
if(ClientIndex[iClient] > 0
        
AddUnusualEffect(...)

I do not approve of what it written... but
Whats problem?

Anyway, learn new syntax.
wow, i forgot inserting Unusualeffect into playersay.
thanks i will try it
marih is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-27-2015 , 08:17   Re: how to pause plugin until one function returns value?
Reply With Quote #6

try this:
PHP Code:
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
{
    
AddUnusualEffect(client, ...); //Replace with ... with the rest of params.

__________________
WildCard65 is offline
neatek
AlliedModders Donor
Join Date: Jul 2010
Location: Russia
Old 02-27-2015 , 08:21   Re: how to pause plugin until one function returns value?
Reply With Quote #7

[OFFTOPIC]
Quote:
Originally Posted by marih View Post
wow, i forgot inserting Unusualeffect into playersay.
thanks i will try it

[/OFFTOPIC]
__________________
neatek is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-27-2015 , 11:52   Re: how to pause plugin until one function returns value?
Reply With Quote #8

I'm going to remind you that RegConsoleCmd (and its fraternal twin RegAdminCmd) register chat commands for the command with / and ! in front of it.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 14:09.


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