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

Compilation errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AcePL96
Junior Member
Join Date: Jun 2020
Old 01-08-2021 , 21:04   Compilation errors
Reply With Quote #1

Hello, I have a problem with compiling this plugin.


Code:
//// szukaj.sp
//
// szukaj.sp(32) : error 033: array must be indexed (variable "kolejka")
// szukaj.sp(34) : error 033: array must be indexed (variable "kolejka")
// szukaj.sp(36) : error 047: array sizes do not match, or destination array is too small
// szukaj.sp(70) : error 047: array sizes do not match, or destination array is too small
// szukaj.sp(83) : error 033: array must be indexed (variable "kolejka")
// szukaj.sp(85) : error 047: array sizes do not match, or destination array is too small
// szukaj.sp(113) : error 035: argument type mismatch (argument 1)
// szukaj.sp(115) : error 035: argument type mismatch (argument 1)
// szukaj.sp(117) : error 035: argument type mismatch (argument 1)
// szukaj.sp(118) : error 035: argument type mismatch (argument 1)
// szukaj.sp(119) : error 047: array sizes do not match, or destination array is too small
// szukaj.sp(126) : error 035: argument type mismatch (argument 1)
// szukaj.sp(128) : error 047: array sizes do not match, or destination array is too small

Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <smlib>
#include <colors>
#include <sdkhooks>

int kolejka[10] = -1;

public Plugin myinfo = 
{
    name = "Kolejka H&S",
    author = "Inext",
    description = "",
    version = "",
    url = "https://steamcommunity.com/id/IInextt/"
};
public void OnPluginStart()
{
    RegConsoleCmd("sm_szukaj", cmd_szukaj, "Komenda na dolaczenie do drużyny szukających");
    
    RegConsoleCmd("jointeam", JoinTeam);
    
    HookEvent("round_end", event_round_end);
}
public Action cmd_szukaj(client, args)
{
    for(int i = 0; i < 10; i++)
    {
        int pozycja;
        pozycja = i + 1;
        if(kolejka != client)
        {
            if(kolejka <= 0)
            {
                kolejka = client;
                CPrintToChat(client, "{green}[H&S] {olive} Zostałeś dodany do kolejki Szukających. Jesteś na %i pozycji.", pozycja);
                i = 10;
            }
            if(kolejka[9] > 0)
            {
                CPrintToChat(client, "{green}[H&S] {olive} Aktualnie kolejka do TT jest pełna.");
                i = 10;
            }
        }
        else
        {
            i = 10;
            CPrintToChat(client, "{green}[H&S] {olive} Dołączyłeś już do kolejki. Jesteś na %i pozycji.", pozycja);
        }
    }
}
public Action JoinTeam(client,args)
{
    new String:s_Team[3];
    GetCmdArg(1, s_Team, sizeof(s_Team));
    new i_Team = StringToInt(s_Team);
    if(i_Team == 2)
    {
        CPrintToChat(client, "{green}[H&S] {olive}Dołaczenie do tej drużyny jest możliwe tylko przy pomocy komendy !szukaj");
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
public void OnMapStart()
{
    
    for(int i = 0; i < 11; i++)
    {
        kolejka = -1;
    }
}
public void OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_PreThink, Prethink);
}
public void OnClientDisconnect(int client)
{
    SDKUnhook(client, SDKHook_PreThink, Prethink);
    
    for(int i = 0; i < 10; i++)
    {
        if(kolejka == client)
        {
            kolejka = -1;
            for(int x = 0; x < (10 - i); x++)
            {
                kolejka[i+x] = kolejka[i+1+x];
            }
        }
    }
}
public Action Prethink(int client)
{
    PokazKolejkaHud(client);
    return Plugin_Continue;
}
public Action event_round_end(Handle event, const char[] name, bool dontBroadcast)
{
    for (int i; i <= MAXPLAYERS; i++)
    {
        if(IsValidPlayer(i))
        {
            if(GetClientTeam(i) == 2)
            {
                CS_SwitchTeam(i, 3);
            }
        }
    }
    
    for(int i = 0; i < 10; i++)
    {
        if(IsValidPlayer(kolejka))
        {
            if(GetClientTeam(kolejka) != 2)
            {
                CS_SwitchTeam(kolejka, 3);
                CPrintToChat(kolejka, "{green}[H&S] {olive} Zostałeś przeniesiony do TT.");
                kolejka = -1;
                for(int x = 0; x < (10 - i); x++)
                {
                    kolejka[i+x] = kolejka[i+1];
                }
                i--;
            }
            else if(GetClientTeam(kolejka) == 2)
            {
                kolejka = -1;
                for(int x = 0; x < (10 - i); x++)
                {
                    kolejka[i+x] = kolejka[i+1+x];
                }
                i--;
            }
        }
    }
    
    if(Team_GetClientCount(2) == 0)
    {
        int random = GetRandomPlayer(3); 
        CS_SwitchTeam(random, 2);
        CPrintToChat(random, "{green}[H&S] {olive} Zostałeś przeniesiony do TT.");
    }
}
void PokazKolejkaHud(client)
{
    char text[128];
    if(kolejka[0] > 0)
    {
        char nickGracz[64];
        GetClientName(kolejka[0], nickGracz, sizeof(nickGracz));
        Format(text, sizeof(text), "Nestępny w Kolejce:\n%s", nickGracz);
    }
    else
    {
        Format(text, sizeof(text), "Następny w Kolejce:\nBrak Chętnych");
    }
    SetHudTextParams(0.13, 0.10, 7.0, 45, 209, 0, 255, 0, 0.25, 1.5, 0.5);
    ShowHudText(client, 2, text);
}
stock GetRandomPlayer(team) 
{

    new clients[MaxClients+1], clientCount;
    for (new i = 1; i <= MaxClients; i++)
        if (IsClientInGame(i) && (GetClientTeam(i) == team))
            clients[clientCount++] = i;
    return (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount-1)];
} 
stock bool IsValidPlayer(client)
{
    if(client >= 1 && client <= MaxClients && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client) && !IsClientSourceTV(client))
    {
        return true;
    }
    else
        return false;
}
Attached Files
File Type: sp Get Plugin or Get Source (szukaj.sp - 68 views - 4.7 KB)

Last edited by AcePL96; 01-08-2021 at 21:06.
AcePL96 is offline
StrikeR14
AlliedModders Donor
Join Date: Apr 2016
Location: Behind my PC
Old 01-09-2021 , 12:03   Re: Compilation errors
Reply With Quote #2

Whenever you want to approach a specific cell, you need to specify the index. Calling the array's name is not enough.

(meaning kolejka should be called as kolejka[i] in your errors).
Attached Files
File Type: sp Get Plugin or Get Source (szukaj.sp - 27 views - 4.7 KB)
__________________
Currently taking TF2/CSGO paid private requests!

My Plugins | My Discord Account
StrikeR14 is offline
AcePL96
Junior Member
Join Date: Jun 2020
Old 01-09-2021 , 19:11   Re: Compilation errors
Reply With Quote #3

Plugin don't work

He adds to the queue, but does not transfer "those" people to the terrorists. When the round ends, type !szukaj, writes a message that the queue is full [CPrintToChat(client, "{green}[H&S] {olive} Aktualnie kolejka do TT jest pełna.");]

Last edited by AcePL96; 01-09-2021 at 19:16.
AcePL96 is offline
StrikeR14
AlliedModders Donor
Join Date: Apr 2016
Location: Behind my PC
Old 01-09-2021 , 20:02   Re: Compilation errors
Reply With Quote #4

Apparently it's more compilcated array index than just i, maybe there's more math calculations behind it (like the x+i+1 thing). If this isn't your plugin, then I can't understand what the original author meant.
__________________
Currently taking TF2/CSGO paid private requests!

My Plugins | My Discord Account

Last edited by StrikeR14; 01-09-2021 at 20:03.
StrikeR14 is offline
AcePL96
Junior Member
Join Date: Jun 2020
Old 01-10-2021 , 04:14   Re: Compilation errors
Reply With Quote #5

Got it, I made a balance team with plugin JB.
AcePL96 is offline
Reply


Thread Tools
Display Modes

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 18:32.


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