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

Help compile errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
YesTwiz
AlliedModders Donor
Join Date: May 2018
Old 02-18-2021 , 13:47   Help compile errors
Reply With Quote #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;
}


YesTwiz is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-18-2021 , 16:17   Re: Help compile errors
Reply With Quote #2

You should attach the plugin or put it on [PHP] tag, otherwise will lose all indentation.

EDIT: Seem that this code has been decompiled (even you saying that you wrote that stuff, at least there is a lot of indications that this have been decompiled).

Probably people would have to "rewrite" it, is not a simple "don't compile" I noticed a lot of errors, missing vars and non-sense things.
__________________

Last edited by Marttt; 02-18-2021 at 16:29.
Marttt is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 02-26-2021 , 13:32   Re: Help compile errors
Reply With Quote #3

Decompiled plugins replace some code to make it easier to "understand" what's there. Therefore, you shouldn't use the decompile option if you don't even know how to code a sourcemod plugin properly. If you could give us the original .sp, that'll be nice even though, it should be able to compile.
__________________
SpirT 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 08:01.


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