AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Messages do not display (https://forums.alliedmods.net/showthread.php?t=341470)

szogun 01-23-2023 11:47

Messages do not display
 
hey , will you help me to make the plug-in correctly, I unfortunately no longer have the skills to make it work

PHP Code:

#include <sourcemod>

#pragma newdecls required
#pragma semicolon 1

#define MAX_PLAYERS 32
int ReklamaHint[MAX_PLAYERS+1];

g_sAdverts[][] = {
"<b><font color='#23f911' class='fontSize-xl'>BONUS</font></b> \n <font class='fontSize-l'>Chcesz co rundę otrzymywać bonusy? \n Dołącz do naszego <b><font color='#ff0000' class='fontSize-l'>Discorda</font></b> \n",
"Reklama 2",
"Reklama 3"};

public 
void OnClientPutInServer(int client)
{
    
ReklamaHint[client] = 0;
}

public 
void OnPluginStart() {
    
HookEvent("round_freeze_end"Event_RoundStart);
}

public 
Action Event_RoundStart(Event eEvent, const char[] namebool dontBroadcast) {
    
int client GetClientOfUserId(GetEventInt(eEvent"userid"));
    
CreateTimer(10.0HintMessageclientTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action HintMessage(Handle timerint client){
    if(!
IsValidClient(client)) return;
        
PrintToChat(client,"timer"); //debug

    
char sBuffer[1024];
    
Format(sBuffer,sizeof(sBuffer),"%s",g_sAdverts[ReklamaHint[client]]);
        
PrintToChat(client,"showwinpanel"); //debug
    
Event    eEvent CreateEvent("cs_win_panel_round"true);
            
eEvent.SetString("funfact_token"sBuffer);
            
eEvent.FireToClient(client);
            
eEvent.Cancel();

            
CreateTimer(10.0cswinpanelclearclientTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action cswinpanelclear(Handle timerint client){
    
PrintToChat(client,"clearwinpanel"); //debug
    
Event eEvent CreateEvent("cs_win_panel_round"true);
    
eEvent.SetString("funfact_token""");
    
eEvent.FireToClient(client);
    
eEvent.Cancel();
}

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



Marttt 01-23-2023 12:53

Re: Messages do not display
 
round_freeze_end does not have the "userid" parameter AFAIK,
do a for loop through all connected clients instead

Grey83 01-25-2023 10:47

Re: Messages do not display
 
PHP Code:

#pragma newdecls required
#pragma semicolon 1

#define MAX_PLAYERS 32

static const char ADVERTS[][] =
{
    
"<b><font color='#23f911' class='fontSize-xl'>BONUS</font></b> \n <font class='fontSize-l'>Chcesz co rundę otrzymywać bonusy? \n Dołącz do naszego <b><font color='#ff0000' class='fontSize-l'>Discorda</font></b> \n",
    
"Reklama 2",
    
"Reklama 3"
};

Handle
    hTimer
[2];
int
    iAds
[MAX_PLAYERS+1];

public 
void OnClientDisconnect(int client)
{
    
iAds[client] = 0;
}

public 
void OnPluginStart()
{
    
HookEvent("round_freeze_end"Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void OnMapStart()
{
    if(
hTimer[0]) delete hTimer[0];
    if(
hTimer[1]) delete hTimer[1];
}

public 
void OnMapEnd()
{
    
OnMapStart();
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
OnMapStart();
    
hTimer[0] = CreateTimer(10.0HintMessage);
}

public 
Action HintMessage(Handle timer)
{
    if(
hTimer[1]) delete hTimer[1];

    
bool show;
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i) && iAds[i] < sizeof(ADVERTS))
    {
        
SendWinPanel(iADVERTS[iAds[i]]);
        
iAds[i]++;
        
show true;
    }
    if(
showhTimer[1] = CreateTimer(10.0cswinpanelclear);

    
hTimer[0] = null;
    return 
Plugin_Stop;
}

public 
Action cswinpanelclear(Handle timer)
{
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i) && iAds[i] <= sizeof(ADVERTS))
    {
        
SendWinPanel(i);
        
iAds[i]++;
    }

    
hTimer[1] = null;
    return 
Plugin_Stop;
}

void SendWinPanel(int clientchar[] txt "")
{
    
Event event CreateEvent("cs_win_panel_round"true);
    
event.SetString("funfact_token"txt);
    
event.FireToClient(client);
    
event.Cancel();



szogun 01-29-2023 08:56

Re: Messages do not display
 
Quote:

Originally Posted by Grey83 (Post 2797949)
PHP Code:

#pragma newdecls required
#pragma semicolon 1

#define MAX_PLAYERS 32

static const char ADVERTS[][] =
{
    
"<b><font color='#23f911' class='fontSize-xl'>BONUS</font></b> \n <font class='fontSize-l'>Chcesz co rundę otrzymywać bonusy? \n Dołącz do naszego <b><font color='#ff0000' class='fontSize-l'>Discorda</font></b> \n",
    
"Reklama 2",
    
"Reklama 3"
};

Handle
    hTimer
[2];
int
    iAds
[MAX_PLAYERS+1];

public 
void OnClientDisconnect(int client)
{
    
iAds[client] = 0;
}

public 
void OnPluginStart()
{
    
HookEvent("round_freeze_end"Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void OnMapStart()
{
    if(
hTimer[0]) delete hTimer[0];
    if(
hTimer[1]) delete hTimer[1];
}

public 
void OnMapEnd()
{
    
OnMapStart();
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
OnMapStart();
    
hTimer[0] = CreateTimer(10.0HintMessage);
}

public 
Action HintMessage(Handle timer)
{
    if(
hTimer[1]) delete hTimer[1];

    
bool show;
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i) && iAds[i] < sizeof(ADVERTS))
    {
        
SendWinPanel(iADVERTS[iAds[i]]);
        
iAds[i]++;
        
show true;
    }
    if(
showhTimer[1] = CreateTimer(10.0cswinpanelclear);

    
hTimer[0] = null;
    return 
Plugin_Stop;
}

public 
Action cswinpanelclear(Handle timer)
{
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i) && iAds[i] <= sizeof(ADVERTS))
    {
        
SendWinPanel(i);
        
iAds[i]++;
    }

    
hTimer[1] = null;
    return 
Plugin_Stop;
}

void SendWinPanel(int clientchar[] txt "")
{
    
Event event CreateEvent("cs_win_panel_round"true);
    
event.SetString("funfact_token"txt);
    
event.FireToClient(client);
    
event.Cancel();



PHP Code:

static const char ADVERTS[][] =
{
"<b><font color='#23f911' class='fontSize-xxl'>BONUS</font></b> \n <font class='fontSize-l'>Chcesz co rundę otrzymywać bonusy? \n Dołącz do naszego <b><font color='#ff0000' class='fontSize-l'>Discorda</font></b> \n Link do discord pod komendą <b><font color='#ff0000' class='fontSize-l'>!dc</font></b> \n",
"<b><font color='#23f911' class='fontSize-xxl'>KONKURS</font></b> \n <b><font color='#ff0000' class='fontSize-l'>TOP3</font></b> osoby dostają VIPA \n Nagrodę odbieramy na <b><font color='#ff0000' class='fontSize-l'>Discord</font></b> \n Link do discord pod komendą <b><font color='#ff0000' class='fontSize-l'>!dc</font></b> \n",
"<b><font color='#23f911' class='fontSize-xxl'>֎</font></b> \n <font class='fontSize-l'>Z Vipem zawsze lepiej</font> \n <font color='#32ff00' class='fontSize-l'><b>TAB</b></font> -> <font color='#32ff00' class='fontSize-l'><b>Strona serwera</b></font> \n lub \n <font color='#32ff00' class='fontSize-l'><b>sklep.onefrag.pl</b></font> | <font color='#32ff00' class='fontSize-l'><b>!sklepsms</b></font> \n",
"<b><font color='#23f911' class='fontSize-xxl'>SKLEPSMS</font></b> \n <font class='fontSize-l'>Usługę VIP, kupisz w</font> <b><font color='#32ff00' class='fontSize-l'>!sklepsms</font></b> \n <font class='fontSize-l'>Dostępne metody płatności</font> <font color='#32ff00' class='fontSize-l'>SMS, PSC, Przelew, PayPal, Skiny</font> \n",
"<b><font color='#23f911' class='fontSize-xxl'>REKRUTACJA</font></b> \n <font class='fontSize-l'>Rekrutacja na Admina jest</font> <b><font color='#32ff00' class='fontSize-l'>OTWARTA!</font></b> \n <font class='fontSize-l'>Zachęcamy do składania podań, na <b></font> <font color='#32ff00' class='fontSize-l'>discord</font></b> \n Link do discord pod komendą <b><font color='#32ff00' class='fontSize-l'>!dc</font></b> \n",
"<b><font color='#23f911' class='fontSize-xxl'>ULUBIONE</font></b> \n <font class='fontSize-l'>Nie zapomnij dodać serwera do Ulubionych! \n </font> <b><font color='#ff0000' class='fontSize-l'>ESC</font></b> -> <b><font color='#ff0000' class='fontSize-l'>Wyszukiwarka serwerów społecznościowych</font></b> -> <b><font color='#ff0000' class='fontSize-l'>Ulubione</font></b> -> <b><font color='#ff0000' class='fontSize-l'>Dodaj ten serwer</font></b> \n"}; 

Hey, thank you for doing this, can you still tell me why it only displays the first three ads here and then no longer loops it to show them again

Grey83 01-29-2023 10:10

Re: Messages do not display
 
Quote:

Originally Posted by szogun (Post 2798236)
why it only displays the first three ads here and then no longer loops it to show them again

PHP Code:

#pragma newdecls required
#pragma semicolon 1

#define MAX_PLAYERS 32

static const char ADVERTS[][] =
{
    
"Reklama 1",
    
"Reklama 2",
    
"Reklama 3"
};

Handle
    hTimer
[2];
int
    iAds
[MAX_PLAYERS+1];

public 
void OnClientDisconnect(int client)
{
    
iAds[client] = 0;
}

public 
void OnPluginStart()
{
    
HookEvent("round_freeze_end"Event_RoundStartEventHookMode_PostNoCopy);
}

public 
void OnMapStart()
{
    if(
hTimer[0]) delete hTimer[0];
    if(
hTimer[1]) delete hTimer[1];
}

public 
void OnMapEnd()
{
    
OnMapStart();
}

public 
void Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
OnMapStart();
    
hTimer[0] = CreateTimer(10.0HintMessage);
}

public 
Action HintMessage(Handle timer)
{
    if(
hTimer[1]) delete hTimer[1];

    
bool show;
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i))
    {
        
SendWinPanel(iADVERTS[iAds[i]]);
        if(++
iAds[i] >= sizeof(ADVERTS)) iAds[i] = 0;
        
show true;
    }
    if(
showhTimer[1] = CreateTimer(10.0cswinpanelclear);

    
hTimer[0] = null;
    return 
Plugin_Stop;
}

public 
Action cswinpanelclear(Handle timer)
{
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i)) SendWinPanel(i);

    
hTimer[1] = null;
    return 
Plugin_Stop;
}

void SendWinPanel(int clientchar[] txt "")
{
    
Event event CreateEvent("cs_win_panel_round"true);
    
event.SetString("funfact_token"txt);
    
event.FireToClient(client);
    
event.Cancel();



Bacardi 01-30-2023 15:23

Re: Messages do not display
 
Quote:

Originally Posted by szogun (Post 2798236)
Hey, thank you for doing this, can you still tell me why it only displays the first three ads here and then no longer loops it to show them again

Do you get any errors in sourcemod logs ?

Grey83 01-30-2023 23:06

Re: Messages do not display
 
Quote:

Originally Posted by Bacardi (Post 2798308)
Do you get any errors in sourcemod logs ?

Because I made it so that it shows all messages only once.


All times are GMT -4. The time now is 03:43.

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