This piece of code, specifically GetCryOutNumber, spouted so much compile errors that I can't pinpoint to; the errors only happen after the first else. I've already updated to the latest sourcemod, and this still happens.
char GetCryOutNumber(const char cl_survname, const char cl_victimname)
{
char temp_str[16];
if (StrEqual(cl_survname, "gambler", false))
{
if (StrEqual(cl_victimname, "rochelle", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "01";
case 2:return "12";
}
} else if (StrEqual(cl_victimname, "coach", false)) {
switch (GetRandomInt(1, 2)) {
Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(1, 2)); return temp_str;
}
} else if (StrEqual(cl_victimname, "ellis", false)) {
switch (GetRandomInt(1, 3)) {
case 1:return "04";
case 2:return "07";
case 3:return "13";
}
}
}
// omae wa mou shindeiru
// NANI?!
else if (StrEqual(cl_survname, "producer", false))
{
if (StrEqual(cl_victimname, "nick", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "09";
case 2:return "10";
}
} else if (StrEqual(cl_victimname, "coach", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "03";
case 2:return "05";
}
} else if (StrEqual(cl_victimname, "ellis", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "01";
case 2:return "05";
}
}
}
else if (StrEqual(cl_survname, "coach", false))
{
if (StrEqual(cl_victimname, "nick", false)) {
switch (GetRandomInt(1, 4)) {
case 1:return "01";
case 2:return "05";
case 3:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(7, 8));
}
} else if (StrEqual(cl_victimname, "rochelle", false)) {
Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(7, 8)); return temp_str;
} else if (StrEqual(cl_victimname, "ellis", false)) {
switch (GetRandomInt(1, 2)) {
case 1:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(1, 2)); return temp_str;
case 2:return "04";
}
}
}
else if (StrEqual(cl_survname, "mechanic", false))
{
if (StrEqual(cl_victimname, "nick", false)) {
switch (GetRandomInt(1, 3)) {
case 1:return "01";
case 2:return "13";
case 3:return "15";
}
} else if (StrEqual(cl_victimname, "rochelle", false)) {
switch (GetRandomInt(1, 3)) {
case 1:return "02";
case 2:Format(temp_str, sizeof(temp_str), "1%i", GetRandomInt(2, 3)); return temp_str;
case 3:return "15";
}
} else if (StrEqual(cl_victimname, "coach", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "04";
case 2:return "07";
}
}
}
else if (StrEqual(cl_survname, "teenangst", false))
{
if (StrEqual(cl_victimname, "bill", false)) {
switch (GetRandomInt(1, 10)) {
case 1:return "01";
case 2:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(3, 4)); return temp_str;
case 3:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(6, 7)); return temp_str;
case 4:return "09";
case 5:Format(temp_str, sizeof(temp_str), "1%i", GetRandomInt(0, 3)); return temp_str;
case 6:Format(temp_str, sizeof(temp_str), "1%i", GetRandomInt(5, 7)); return temp_str;
case 7:Format(temp_str, sizeof(temp_str), "2%i", GetRandomInt(2, 3)); return temp_str;
case 8:return "26";
case 9:return "28";
case 10:return "30";
}
} else if (StrEqual(cl_victimname, "francis", false)) {
switch (GetRandomInt(1, 3)) {
case 1:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(2, 6)); return temp_str;
case 2:return "09";
case 3:Format(temp_str, sizeof(temp_str), "1%i", GetRandomInt(0, 2)); return temp_str;
case 4:return "07";
case 5:Format(temp_str, sizeof(temp_str), "2%i", GetRandomInt(0, 3)); return temp_str;
}
} else if (StrEqual(cl_victimname, "louis", false)) {
switch (GetRandomInt(1, 2)) {
case 1:return "01";
case 2:Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(4, 6)); return temp_str;
}
}
}
else if (StrEqual(cl_survname, "namvet", false) || StrEqual(cl_survname, "biker", false) ||
StrEqual(cl_survname, "manager", false))
{
Format(temp_str, sizeof(temp_str), "0%i", GetRandomInt(1, 2)); return temp_str;
}
return "";
}
bool IsValidClient(client, bool replaycheck = true)
//IsValidClient(client)
{
if (!IsValidEntity(client)) return false;
if (client <= 0 || client > MaxClients) return false;
if (!IsClientInGame(client)) return false;
//if (GetEntProp(client, Prop_Send, "m_bIsCoaching")) return false;
if (replaycheck)
{
if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
}
return true;
}
bool IsSurvivor(client)
{
if (!IsValidClient(client)) return false;
if (GetClientTeam(client) == SURVIVORTEAM || GetClientTeam(client) == SURVIVORTEAM_PASSING) return true;
return false;
}
Code:
C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(757) : error 010: invalid function or declaration
// C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(759) : error 010: invalid function or declaration
// C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(760) : error 010: invalid function or declaration
// C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(761) : error 010: invalid function or declaration
// C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(762) : error 010: invalid function or declaration
// C:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\L4D_DeadRinger.sp(764) : error 010: invalid function or declaration
This was only a quarter of the spammed errors from the compiler.
EDIT: After forcing and converting the plugin into new syntax, (turns out it was all just an easy fix and one guess) there's now an additional error popping up at the top of the error spam:
Even though this looks like the cause of all this, I still don't get it. On Notepad++ the reported brace is lining up perfectly with the other brace, securing the function in. How could this happen?
One thing I noticed is the char functions need to be char[]. They must return a variable, not a const, meaning anything with quotes or brackets. You also cant initialize arrays with a non constant. It must first be declared, then set. Here is a working example:
One thing I noticed is the char functions need to be char[]. They must return a variable, not a const, meaning anything with quotes or brackets. You also cant initialize arrays with a non constant. It must first be declared, then set. Here is a working example:
Sourcepawn also does not allow string comparisons with ==. Use StrEqual or do someString[0] == '\0' to check if string is empty.
Thanks for those suggestions as well as reminding me not to compare strings using == (I had an obscure feeling that something was wrong when I did that)
Unfortunately the main problem still exists - the compiling is screwed over after the else part.
I don't know why, but the compiler's failing and I do not know why or how. One of the lines it reports is: else if (StrEqual(cl_survname, "producer", false))
when there was another line before that used the EXACT same function: if (StrEqual(cl_survname, "gambler", false))
It could be the else that is broken, but I don't know why...?