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

newevent message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 11-08-2022 , 05:39   newevent message
Reply With Quote #1

Hey, I'm a beginner and I'm trying to do an end-of-round ad in cs_win_panel_round but it doesn't work for me at all

PHP Code:
#include <sourcemod>
#include <sdkhooks>

#define MAX_PLAYERS 64

int Advertising[MAX_PLAYERS+1];

public 
void OnClientPutInServer(int client)
{
    
Advertising[client] = 0;
        
HookEvent("cs_win_panel_round"cs_win_panel_roundEventHookMode_Pre);
}

public 
Action cs_win_panel_round(Event event, const char[] namebool dontBroadcast){
  
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
IsValidClient(client)) return;
      switch(
Advertising[client]){
      case 
1:{         
      
Event newevent_message CreateEvent("cs_win_panel_round");
      
newevent_message.SetString("funfact_token""<b><font size='15' color='#ffa500'>TEXT TEXT</font></b>");  //⊛

      
for(int z 1<= MaxClientsz++)
        if(
IsClientInGame(z) && !IsFakeClient(z))
          
newevent_message.FireToClient(z);                                           

        
newevent_message.Cancel(); 
    }
      case 
2:{
      
Event newevent_message CreateEvent("cs_win_panel_round");
      
newevent_message.SetString("funfact_token""<b><font size='15' color='#ffa500'>TEXT2 TEXT2</font></b>");  

      for(
int z 1<= MaxClientsz++)
        if(
IsClientInGame(z) && !IsFakeClient(z))
          
newevent_message.FireToClient(z);                                           

        
newevent_message.Cancel(); 
    }
  }
  
Advertising[client]++;
  if(
Advertising[client] > 2Advertising[client] = 1;
}

stock bool IsValidClient(int client)
{
    if(
client >= && client <= MaxClients && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client) && !IsClientReplay(client) && !IsClientSourceTV(client))
        return 
true;
    return 
false;


Last edited by szogun; 11-08-2022 at 05:39.
szogun is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-08-2022 , 07:45   Re: newevent message
Reply With Quote #2

Usually, you hook events OnPluginStart.

Also, cs_win_panel_round doesn't have a "userid" AFAIK so your "IsValidClient" always returns false and so your code does nothing.

Is good practice to mention the game (CSS/CSGO?), cause there are a lot of games supported by Sourcemod, and some may differ in similar things (like diff args on events)

Giving basic information will speed up the process of someone replying and helping you.
__________________

Last edited by Marttt; 11-08-2022 at 07:47.
Marttt is offline
szogun
Senior Member
Join Date: Apr 2016
Old 11-08-2022 , 19:12   Re: newevent message
Reply With Quote #3

csgo, aha, so my thought is bad, so I have no ideas how to do it
szogun 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 16:29.


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