How to send this string
#1

Here's my main callback

PHP код:
public OnPlayerConnect(playerid)
{
     for(new 
0MAX_PLAYERSi++)
        if(
IsPlayerConnected(i)&& playerid != i)
        {
        new 
name[MAX_PLAYER_NAME], country[MAX_COUNTRY_NAME], gmt;
        new 
str2[256];
        
GetPlayerName(playeridnamesizeof(name));
        
country GetPlayerCountryName(playerid);
        
gmt GetPlayerGMT(playerid);
        
format(str2sizeof(str2), "* %s %s(%d) has connected to the server from %s (GMT %d:00)",rankings,name,playeridcountrygmt);//Focus on the rankings only
        
SendClientMessageToAll(concolor,str2);
        return 
1;
        } 
Now, How and Where do I put this rankings
PHP код:
if(GetPlayerScore(playerid) > && GetPlayerScore(playerid) < 10))
     {
         
SCM(playeridconcolor"Newbie");
     }
     else if(
GetPlayerScore(playerid) > 10 && GetPlayerScore(playerid) < 50)
     {
         
SCM(playeridconcolor"Trucker");
     }
     else if(
GetPlayerScore(playerid) > 50 && GetPlayerScore(playerid) < 100)
     {
         
SCM(playeridconcolor"Experienced Trucker");
     }
     else if(
GetPlayerScore(playerid) > 100 && GetPlayerScore(playerid) < 300)
     {
         
SCM(playeridconcolor"Elite");
     }
     else if(
GetPlayerScore(playerid) >= 300)
     {
         
SCM(playeridconcolor"Captain");
     } 
So that when a player connects, this message sends to all
PHP код:
Newbie John(0has connected to the server from ----- (GMT --:--) 
**Don't mind the other params, only the ranking string is my problem
Reply
#2

- There is no need for that loop if you're going to use SendClientMessageToAll in there, especially as you have return 1; at the end of the loop too.

- The above also makes the if statement under it, non-necessary too.

pawn Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], country[MAX_COUNTRY_NAME], gmt, str2[256], pScore, rankings[20];
    GetPlayerName(playerid, name, sizeof(name));
    country = GetPlayerCountryName(playerid);
    pScore = GetPlayerScore(playerid);
    gmt = GetPlayerGMT(playerid);
    if(pScore < 10)
    {
        rankings = "Newbie";
    }
    else if(pScore >= 10 && pScore < 50)
    {
        rankings = "Trucker";
    }
    else if(pScore >= 50 && pScore < 100)
    {
        rankings = "Experienced Trucker";
    }
    else if(pScore >= 100 && pScore < 300)
    {
        rankings = "Elite";
    }
    else
    {
        rankings = "Captain";
    }
    format(str2, sizeof(str2), "* %s %s(%d) has connected to the server from %s (GMT %d:00)", rankings, name, playerid, country, gmt);
    SendClientMessageToAll(concolor,str2);
    return 1;
}
- Since this is all in OnPlayerConnect, all players will have 0 score, so the ranking can only really be done well after the player logs in / registers.
Reply
#3

So what you're saying here is, when the player logs in or finished registering, it will THEN send the message to all players?

Or

Even though the player hasn't logged in or registered it will THEN send the message
Reply
#4

Neither, if you have that code in OnPlayerConnect it will create that line when a player connects. Since the player hasn't had a chance to log in yet, their score will be 0.

So you could either:
- Move the code to display that line after they log in / register.
- Upon connecting, you can read the account data for the account score and use that instead of GetPlayerScore.
- Or just not display the ranking at all.
Reply
#5

Quote:
Originally Posted by Ray0
Посмотреть сообщение
Neither, if you have that code in OnPlayerConnect it will create that line when a player connects. Since the player hasn't had a chance to log in yet, their score will be 0.

So you could either:
- Move the code to display that line after they log in / register.
- Upon connecting, you can read the account data for the account score and use that instead of GetPlayerScore.
- Or just not display the ranking at all.
1. The code which has login/register is still on the OnPlayerConnect callback, or do I have to move the rankings somewhere below it?
2. I'll try that and see if that will work well
3. That's why I posted this thread, to get help cause I want to use it

EDIT: Also, I tried your code, and it doesn't seem to work
Reply
#6

The player's score is saved when he disconnect?
Reply
#7

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
The player's score is saved when he disconnect?
Yes it does, as it seems to be pretty useless using this code without scores saving on disconnect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)