Author Topic: Help !Top  (Read 5605 times)

0 Members and 1 Guest are viewing this topic.

Offline DivX

  • Street Thug
  • *
  • Posts: 11
    • View Profile
Help !Top
« on: February 27, 2011, 04:08:20 pm »
Help Me

Command

        !Top

  3  Top players
------------------------------------------------
1)[DF]Divx 50-Kills 30 Death

2)[DF]MadnesS 49-Kills 9-Death

3)[DF]Dr.Dre 20-Kills 90-Death

Help Me Plz
   

Offline theway

  • Street Thug
  • *
  • Posts: 20
    • View Profile
Re: Help !Top
« Reply #1 on: February 27, 2011, 04:18:21 pm »
I don't know  what your say

Offline [AoD]NC

  • VC:MP Beta Tester
  • VC:MP Veteran
  • *
  • Posts: 616
  • AoD forever!
    • View Profile
    • KURWA MAĆ
Re: Help !Top
« Reply #2 on: February 28, 2011, 01:14:10 am »
He wants top 3 players online/overall with best kill rate/ratio?

Offline theway

  • Street Thug
  • *
  • Posts: 20
    • View Profile
Re: Help !Top
« Reply #3 on: February 28, 2011, 07:12:30 am »
GetPlayerScore(playerid)   and Sentmess..  to player,  easy,  but u type F5, u can see player score, not?

Offline BIG[H]

  • Made Man
  • ***
  • Posts: 159
  • Sight of light
    • View Profile
Re: Help !Top
« Reply #4 on: February 28, 2011, 12:31:02 pm »
Max Players Online ?? easy just edit !admin from gups xD
Outdoor city server Administrator, FS server owner!

Offline DivX

  • Street Thug
  • *
  • Posts: 11
    • View Profile
Re: Help !Top
« Reply #5 on: March 01, 2011, 03:16:33 am »
Yes carolina that's the point  ;)

yazeen

  • Guest
Re: Help !Top
« Reply #6 on: March 13, 2011, 10:53:29 am »
Lol the best and simple way is-

SendClientMessage[/glow][/shadow]

Regards by yazeen

Offline shivambansal

  • Wiseguy
  • **
  • Posts: 52
  • VC:MP Beta Tester
    • View Profile
Re: Help !Top
« Reply #7 on: March 13, 2011, 05:37:10 pm »
lol i think he means !rank ;D

Offline DivX

  • Street Thug
  • *
  • Posts: 11
    • View Profile
Re: Help !Top
« Reply #8 on: April 18, 2011, 07:37:42 pm »
yes shivambansal
 ???

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Help !Top
« Reply #9 on: April 18, 2011, 09:58:40 pm »
All users overall
(warning: this will become more resource intensive as more users sign up)

Put this code in OnPlayerCommandText():
Code: [Select]
// Show the best players overall
else if(strcmp(cmd, "topoverall", true) == 0)
{
// Declare some variables that we'll need
new topUser1[2][128],
topUser2[2][128],
topUser3[2][128],
userFile[64],
Float:deaths,
Float:kills,
Float:ratio,
sRatio[10],
nick[128],
i,
j;

// Set the default ratios for our top users
topUser1[1] = "0.00";
topUser2[1] = "0.00";
topUser3[1] = "0.00";

// Get the total number of known users.
j = dini_Int("/AllUsers.ini", "Index");

// Iterate through all known users
for(i = 1; i < j + 1; i++)
{
// Get this person's nickname.
nick = dini_Get("/AllUsers.ini", IntToStr(i));

// Find this user's file.
format
(
// String formatting
userFile,
sizeof(userFile),
"/Users/%s.ini",

// Variables, respectively
nick
);

// Get their kills and deaths.
kills  = dini_Int(userFile, "Kills");
deaths = dini_Int(userFile, "Deaths");

// Now find their K/D ratio.
ratio = floatdiv(kills, deaths);

// Is this ratio better than the current first-place holder's?
if(ratio > floatstr(topUser1[1]))
{
// Is there a person in first place?
if(floatstr(topUser1[1]) > 0)
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;

// Move the previous first place winner to second place
topUser2 = topUser1;
}
// Nope
else
{
// Move the previous first place winner to second place
topUser2 = topUser1;
}
}

// Set them as first-place.
topUser1[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser1[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than second-place?
else if(ratio > floatstr(topUser2[1]))
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;
}

// Set them as second-place.
topUser2[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser2[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than third-place?
else if(ratio > floatstr(topUser3[1]))
{
// Yes. Set them as third-place.
topUser3[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser3[1] = sRatio;

// Done here.
continue;
}
// They did not rank in the Top 3.
else
{
continue;
}
}

// Start posting the top three
SendClientMessageToAll(COLOR_YELLOW, "** Top Three Players **");

// Format a message string for first place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"1. %s - %.2f",

// Variables, respectively
topUser1[0],
floatstr(topUser1[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for second place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"2. %s - %.2f",

// Variables, respectively
topUser2[0],
floatstr(topUser2[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for third place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"3. %s - %.2f",

// Variables, respectively
topUser3[0],
floatstr(topUser3[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Done.
return 1;
}

Put this code in OnGameModeInit():
Code: [Select]
// Create the all users INI if it does not exist
if(!dini_Exists("/AllUsers.ini"))
{
    // Create it with an index of 0 for no users
    dini_Create("/AllUsers.ini");
    dini_IntSet("/AllUsers.ini", "Index", 0);
}

Put this code in OnPlayerConnect() under if(dini_Exists(file)):
Code: [Select]
// Add them to the All Users INI if they aren't in it
new j = dini_Int("/AllUsers.ini", "Index"),
i,
found = 0,
result[128];

// Iterate through all users
for(i = 1; i < j + 1; i++)
{
// Get this user's nick.
result = dini_Get("/AllUsers.ini", IntToStr(i));

// This is them.
if(strcmp(result, gPlayers[playerid], true) == 0)
{
// Found them!
found = 1;

// Stop
break;
}
}

// They're not there.
if(found == 0)
{
// Increment the index.
j++;

// Add them to the index.
dini_Set("/AllUsers.ini", IntToStr(j), gPlayers[playerid]);

// Reset the index to variable "j"
dini_IntSet("/AllUsers.ini", "Index", j);
}

Screenshot
Do not PM me for support.




yazeen

  • Guest
Re: Help !Top
« Reply #10 on: April 19, 2011, 06:34:16 am »
All users overall
(warning: this will become more resource intensive as more users sign up)

Put this code in OnPlayerCommandText():
Code: [Select]
// Show the best players overall
else if(strcmp(cmd, "topoverall", true) == 0)
{
// Declare some variables that we'll need
new topUser1[2][128],
topUser2[2][128],
topUser3[2][128],
userFile[64],
Float:deaths,
Float:kills,
Float:ratio,
sRatio[10],
nick[128],
i,
j;

// Set the default ratios for our top users
topUser1[1] = "0.00";
topUser2[1] = "0.00";
topUser3[1] = "0.00";

// Get the total number of known users.
j = dini_Int("/AllUsers.ini", "Index");

// Iterate through all known users
for(i = 1; i < j + 1; i++)
{
// Get this person's nickname.
nick = dini_Get("/AllUsers.ini", IntToStr(i));

// Find this user's file.
format
(
// String formatting
userFile,
sizeof(userFile),
"/Users/%s.ini",

// Variables, respectively
nick
);

// Get their kills and deaths.
kills  = dini_Int(userFile, "Kills");
deaths = dini_Int(userFile, "Deaths");

// Now find their K/D ratio.
ratio = floatdiv(kills, deaths);

// Is this ratio better than the current first-place holder's?
if(ratio > floatstr(topUser1[1]))
{
// Is there a person in first place?
if(floatstr(topUser1[1]) > 0)
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;

// Move the previous first place winner to second place
topUser2 = topUser1;
}
// Nope
else
{
// Move the previous first place winner to second place
topUser2 = topUser1;
}
}

// Set them as first-place.
topUser1[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser1[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than second-place?
else if(ratio > floatstr(topUser2[1]))
{
// Is there a person in second place?
if(floatstr(topUser2[1]) > 0)
{
// Move the previous second place winner to third place
topUser3 = topUser2;
}

// Set them as second-place.
topUser2[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser2[1] = sRatio;

// Done here.
continue;
}
// No, but is it better than third-place?
else if(ratio > floatstr(topUser3[1]))
{
// Yes. Set them as third-place.
topUser3[0] = nick;

// Convert their ratio to a string
format
(
// String formatting
sRatio,
sizeof(sRatio),
"%f",

// Variables, respectively
ratio
);

// Set their ratio as the ratio string
topUser3[1] = sRatio;

// Done here.
continue;
}
// They did not rank in the Top 3.
else
{
continue;
}
}

// Start posting the top three
SendClientMessageToAll(COLOR_YELLOW, "** Top Three Players **");

// Format a message string for first place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"1. %s - %.2f",

// Variables, respectively
topUser1[0],
floatstr(topUser1[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for second place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"2. %s - %.2f",

// Variables, respectively
topUser2[0],
floatstr(topUser2[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Format a message for third place.
format
(
// String formatting
szMsg,
sizeof(szMsg),
"3. %s - %.2f",

// Variables, respectively
topUser3[0],
floatstr(topUser3[1])
);

// Send to everyone
SendClientMessageToAll(COLOR_YELLOW, szMsg);

// Done.
return 1;
}

Put this code in OnGameModeInit():
Code: [Select]
// Create the all users INI if it does not exist
if(!dini_Exists("/AllUsers.ini"))
{
    // Create it with an index of 0 for no users
    dini_Create("/AllUsers.ini");
    dini_IntSet("/AllUsers.ini", "Index", 0);
}

Put this code in OnPlayerConnect() under if(dini_Exists(file)):
Code: [Select]
// Add them to the All Users INI if they aren't in it
new j = dini_Int("/AllUsers.ini", "Index"),
i,
found = 0,
result[128];

// Iterate through all users
for(i = 1; i < j + 1; i++)
{
// Get this user's nick.
result = dini_Get("/AllUsers.ini", IntToStr(i));

// This is them.
if(strcmp(result, gPlayers[playerid], true) == 0)
{
// Found them!
found = 1;

// Stop
break;
}
}

// They're not there.
if(found == 0)
{
// Increment the index.
j++;

// Add them to the index.
dini_Set("/AllUsers.ini", IntToStr(j), gPlayers[playerid]);

// Reset the index to variable "j"
dini_IntSet("/AllUsers.ini", "Index", j);
}

Screenshot


Nice But it may lagg the script! :D