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;
}