AlliedModders Donor
|
02-18-2021
, 13:47
Help compile errors
|
#1
|
I wrote this giveaway script but I'm getting some compile errors I could use some help.
Quote:
kgiveaway.sp(9) : error 010: invalid function or declaration
kgiveaway.sp(16) : error 001: expected token: ";", but found "-identifier-"
kgiveaway.sp(23) : error 010: invalid function or declaration
kgiveaway.sp(26) : error 001: expected token: ";", but found "-identifier-"
kgiveaway.sp(26) : error 010: invalid function or declaration
kgiveaway.sp(26 -- 2 : error 010: invalid function or declaration
kgiveaway.sp(26 -- 2 : fatal error 127: too many error messages on one line
|
Quote:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <colors>
#pragma semicolon 1
bool g_bWarmup_Round;
bool g_bJoined[66];
int g_iHolder;
float g_fTime;
Handle g_hGiveawayTimer;
char g_sPrize[64];
public Plugin myinfo =
{
name = "[Karma] Giveaway",
author = "Twiz",
description = "",
version = "1.0",
url = ""
};
public void ClearTimer2(Handle timer)
{
if (timer)
{
KillTimer(timer, false);
timer = 0;
}
return void 0;
}
public bool IsValidClient(int client, bool alive)
{
int var2;
if (0 < client)
{
return true;
}
return false;
}
public float IntToFloat(int integer)
{
char s[300];
IntToString(integer, s, 300);
return StringToFloat(s);
}
public void OnPluginStart()
{
RegAdminCmd("sm_giveaway", CMD_Giveaway, 4, "Allows an admin to hold a giveaway", "", 0);
RegConsoleCmd("sm_enter", CMD_enter, "Allows a player to enter an ongoing giveaway", 0);
return void 0;
}
public void OnClientDisconnect(int client)
{
g_bWarmup_Round[client] = 0;
if (client == g_iHolder)
{
ClearGiveaway();
}
return void 0;
}
public void ClearGiveaway()
{
g_hGiveawayTimer = 0;
ClearTimer2(g_hGiveawayTimer);
g_iHolder = -1;
g_fTime = 0;
int x = 1;
while (x <= MaxClients)
{
int var1;
if (IsClientInGame(x))
{
g_bWarmup_Round[x] = 0;
x++;
}
x++;
}
return void 0;
}
public Action CMD_enter(int client, int args)
{
if (!IsValidClient(client, false))
{
return Action 3;
}
if (g_iHolder == client)
{
PrintToChat(client, "%s You can't enter your own giveaway!", "[\x02NF\x01]");
return Action 3;
}
int var1;
if (g_hGiveawayTimer)
{
PrintToChat(client, "%s There is no giveaway going on currently!", "[\x02NF\x01]");
return Action 3;
}
if (!g_bWarmup_Round[client])
{
PrintToChat("%s \x04%N\x01 has entered the giveaway for \x04%s\x01 using \x04!enter\x01!", 3220, client, 2636);
g_bWarmup_Round[client] = 1;
}
else
{
PrintToChat(client, "%s You're already entered into this giveaway!");
}
return Action 3;
}
public Action CMD_Giveaway(int client, int args)
{
if (!IsValidClient(client, false))
{
return Action 3;
}
if (args != 2)
{
PrintToChat(client, "%s Usage: sm_giveaway <prize> <seconds>", "[\x02NF\x01]");
return Action 3;
}
if (g_hGiveawayTimer)
{
PrintToChat(client, "%s A giveaway is already going on!", "[\x02NF\x01]");
return Action 3;
}
char bufferArg[28];
GetCmdArg(1, g_sPrize, 255);
GetCmdArg(2, bufferArg, 25);
g_fTime = StringToFloat(bufferArg);
GiveawayMenu(client);
return Action 3;
}
public void OpenGiveaway(int client)
{
g_iHolder = client;
PrintToChat("%s \x04%N has started an open giveaway for \x04%s\x01! The giveaway winner will be chosen in \x01%.0f\x01 seconds!", 3560, client, 2636, 262;
int x = 1;
while (x <= MaxClients)
{
int var1;
if (IsClientInGame(x))
{
g_bWarmup_Round[x] = 1;
x++;
}
x++;
}
g_hGiveawayTimer = CreateTimer(g_fTime, T_GiveawayFinish, any 0, 0);
return void 0;
}
public void ControlledGiveaway(int client)
{
g_iHolder = client;
PrintToChat("%s \x04%N has started a giveaway for \x04%s\x01! Type \x04!enter\x01 to enter! The giveaway winner will be chosen in \x01%.0f\x01 seconds!", 3688, client, 2636, 262;
g_hGiveawayTimer = CreateTimer(g_fTime, T_GiveawayFinish, any 0, 0);
return void 0;
}
public Action T_GiveawayFinish(Handle timer)
{
int iTotal = 0;
int iSpot[64];
int x = 1;
while (x <= MaxClients)
{
int var1;
if (IsClientInGame(x))
{
if (g_bWarmup_Round[x])
{
iSpot[iTotal] = x;
iTotal++;
x++;
}
x++;
}
x++;
}
int iRand = GetRandomInt(0, iTotal);
int iWinner = iSpot[iRand];
PrintToConsole(g_iHolder, "Win client: %i. Win name: %N. Total: %i. Random: %i", iWinner, iWinner, iTotal, iRand);
int var2;
if (iWinner == -1)
{
PrintToChat("%s Giveaway failed!", 3768, iWinner, 2624, 2636);
}
PrintToChat("%s \x04%N\x01 has won \x04%N's\x01 giveaway for \x04%s\x01!", 3820, iWinner, 2624, 2636);
Store_SetClientCredits(%N, Store_GetClientCredits(%s)+creditsgiven);
ClearGiveaway();
return Action 3;
}
|
|
|