Hey guys, im adding some more features to a plugin im working on.
Now the issue is that I can't get it to work correctly
This is how the code looks like
cfg_supporter_total_players = 5
PHP Code:
public showWINNERS(client){
if (g_hDB != INVALID_HANDLE)
{
new String:buffer[200];
Format(buffer, sizeof(buffer), "SELECT * FROM supporter_time ORDER BY total DESC LIMIT %d", GetConVarInt(cfg_supporter_total_players));
SQL_TQuery(g_hDB, SQLWinnersShow, buffer, client);
}
else
{
PrintToChat(client, "Winner System is not available");
}
}
public SQLWinnersShow(Handle:owner, Handle:hndl, const String:error[], any:client){
if(hndl == INVALID_HANDLE)
{
LogError(error);
PrintToServer("SQL Error: %s", error);
return;
}
PrintToChat(client, "\x03Supporter Winners Today:");
PrintToChat(client, "\x03___________________");
new orden = 0;
new count = 0;
new String:number[64];
new String:name[100];
new String:text[128];
if (SQL_HasResultSet(hndl))
{
while (SQL_FetchRow(hndl))
{
orden++;
count++;
Format(number,64, "option%i", orden);
SQL_FetchString(hndl, 1, name, sizeof(name));
new Time = SQL_FetchInt(hndl,4);
new Hours = (Time/60/60);
//new Minutes = (Time/60)%(60);
//new Seconds = (Time%60);
if(Hours >= 1 && orden == 1)
{
PrintToChat(client, "\x03Open Spots (4)");
PrintToChat(client, "\x03___________________");
#if defined DEBUG
PrintToServer("[DEBUG]4 Open Spots");
#endif
}
else if(Hours >= 1 && orden == 2)
{
if(count <= 1)
{
PrintToChat(client, "\x03Open Spots (3)");
PrintToChat(client, "\x03___________________");
#if defined DEBUG
PrintToServer("[DEBUG]3 Open Spots");
#endif
}
}
else if(Hours >= 1 && orden == 3)
{
if(count <= 1)
{
PrintToChat(client, "\x03Open Spots (2)");
PrintToChat(client, "\x03___________________");
#if defined DEBUG
PrintToServer("[DEBUG]2 Open Spots");
#endif
}
}
else if(Hours >= 1 && orden == 4)
{
if(count <= 1)
{
PrintToChat(client, "\x03Open Spots (1)");
PrintToChat(client, "\x03___________________");
#if defined DEBUG
PrintToServer("[DEBUG]1 Open Spots");
#endif
}
}
else if(Hours >= 1 && orden == 5)
{
if(count <= 1)
{
PrintToChat(client, "\x03Open Spots (0)");
PrintToChat(client, "\x03___________________");
#if defined DEBUG
PrintToServer("[DEBUG]0 Open Spots");
#endif
}
}
if(Hours >= 1)
{
Format(text,128, "\x01\x04%i. \x07CC00FF%s", orden,name);
PrintToChat(client, "%s", text);
}
else if(Hours < 1 && orden <= 1)
{
PrintToChat(client, "\x04There is no Winners today yet!");
}
}
}
if(orden < 1)
{
PrintToChat(client, "\x04Database is empty!");
}
//PrintToChat(client, "\x03___________________");
//PrintToChat(client, "\x03Do you like our server?");
//PrintToChat(client, "\x03www.ClanRoyaL.dk/Donate");
//PrintToChat(client, "\x03Donate and get supporter");
}
Now what I want it to do is print out when there is 5/4/3/2/1/0 spots available
Atm it's not doing that.
There can be a total of 5 winning players.
So if there is 3 players that have won, it shows both that there is 4 spots left but also 3 spots and 2.
what I want it to do here is only show that there Is 2 spots left and so on.
This is how the Database table looks like
edit:
nvm I got it working
__________________