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

On Round Start


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 13:33   On Round Start
Reply With Quote #1

Hey Guys,

Have a slight problem,

Trying to get this script to work, to run for every player on round_start

It stops after the first person, Will post what i've got.

PHP Code:
    HookEvent("round_start"RunTest);


public 
RunTest(Handle:event, const String:name[], bool:dontBroadcast)
{
     
    for (new 
idx 0idx <= MaxClientsidx++)
    {
        
PrintToChatAll("Player found");
        
// check if person is in game and not in spec
        
        
if (IsClientConnected(idx))
        {
            
PrintToChatAll("Player is client");
            
// Get the target team
            
decl String:teamString[3];
            
GetCmdArg(1teamStringsizeof(teamString));
            new 
Target_Team StringToInt(teamString);
    
            
decl String:sCookie[5];
            
GetClientCookie(idxg_CT_CookiesCookiesizeof(sCookie));
            new 
iBanStatus StringToInt(sCookie);
            
            
// check for an active ban to send a mesage
            
if ((Target_Team == || Target_Team == 2) && iBanStatus)
            {
                
PrintToChatAll("Player is Terrorist or Spec");
                
// display them a message about the ban
                
new iTimeBanned GetClientCookieTime(idxg_CT_Cookie);
                
decl String:sTimeBanned[150];
                
FormatTime(sTimeBannedsizeof(sTimeBanned), NULL_STRINGiTimeBanned);
                
decl String:sJoinBanMsg[100];
                
GetConVarString(gH_Cvar_JoinBanMessagesJoinBanMsgsizeof(sJoinBanMsg));
                
PrintHintText(idx"%t""Last CT Banned On"sTimeBannedsJoinBanMsg);
            }
            
// otherwise they joined CT or auto-select and are banned
            
else if (iBanStatus)
            {
                
PrintToChatAll("Player is Counter-Terrorist");
                if(
strcmp(gS_SoundPath""))
                {
                    
decl String:buffer[PLATFORM_MAX_PATH 5];
                    
Format(buffersizeof(buffer), "play %s"gS_SoundPath);
                    
ClientCommand(idxbuffer);
                }
                
PrintCenterText(idx"%t""Enforcing CT Ban");
                
UTIL_TeamMenu(idx);
                return 
Plugin_Continue;
            }
            return 
Plugin_Continue;
        }
    }
    return 
Plugin_Continue;

So basically, i want if they join the CT Team, and they're on this banned list, that it brings up the UTIL_TeamMenu.

I don't know where i've gone wrong. (Perhaps coding after a 15 hour shift and being awake for 27 hours.)

Thanks
Paul

Last edited by Capt.Underpants Paul; 08-15-2013 at 13:34. Reason: code tags are handy
Capt.Underpants Paul is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 13:37   Re: On Round Start
Reply With Quote #2

Sorry forgot to add, i threw in the printtochatall's to help debug. It only displays Player Found once, and stops, i put the rest as a comment, and it displayed for all. so, i believe its the if (isclientconnected). I was using if (isclientingame) but tried connected to debug.
Capt.Underpants Paul is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 08-15-2013 , 13:41   Re: On Round Start
Reply With Quote #3

Code:
return Plugin_Continue;
in the for loop ends the function right there and stops it from looping over the other players
Doodil is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 13:47   Re: On Round Start
Reply With Quote #4

God, i'm an idiot, thanks!
Capt.Underpants Paul is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 20:54   Re: On Round Start
Reply With Quote #5

hey sorry,

I've removed them plugin.continue, and it still does just the one person.

any other suggestions?

after a bit of tinkering, it doesn't work after

PHP Code:
            // Get the target team
            
decl String:teamString[3];
            
GetCmdArg(1teamStringsizeof(teamString));
            new 
Target_Team StringToInt(teamString); 

Last edited by Capt.Underpants Paul; 08-15-2013 at 21:05.
Capt.Underpants Paul is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 20:57   Re: On Round Start
Reply With Quote #6

Have you checked /sourcemod/logs for any errors pertaining to this plugin? Your for loop should start at 1, not 0, as that's where your client indexes start.
__________________
thetwistedpanda is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 21:09   Re: On Round Start
Reply With Quote #7

L 08/16/2013 - 11:09:02: [SM] Native "GetCmdArg" reported: No command callback available
L 08/16/2013 - 11:09:02: [SM] Displaying call stack trace for plugin "sm_ctban.smx":
L 08/16/2013 - 11:09:02: [SM] [0] Line 1511, sm_ctban.sp::RunTest()

Directly from the log file.
Capt.Underpants Paul is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 21:10   Re: On Round Start
Reply With Quote #8

There be yer problem. round_start has no arguments being passed. If you want to detect when they join a team, hook the command "jointeam", or the event player_team if you want to handle it after they already change.
__________________
thetwistedpanda is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 08-15-2013 , 21:12   Re: On Round Start
Reply With Quote #9

On the map change, if you join first, it doesn't remove you, thats why i wanted it on round start.

Already have it for jointeam and player_team

could i use player_spawn?
Capt.Underpants Paul is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-15-2013 , 21:14   Re: On Round Start
Reply With Quote #10

I'm having a wee bit of a hard time following what you're doing. Could you give me in depth details of what you want and I'll give you some pseudo example code or point you in the right direction.
__________________
thetwistedpanda 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 05:20.


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