[INFO]IsPlayerConnected
#1

Hello everyone, I would like to hear from you if these features can be good or how I can improve: in OnPlayerDisconnect then how can I do?

public OnPlayerConnect:

Код:
for(new i, MaxPlayers = GetMaxPlayers(); i < MaxPlayers; i++)
{
    if(IsPlayerConnected(i))
    {
    GetPlayerName(playerid, Nome[playerid], 24);
    format(stringa, sizeof stringa, "%s (ID:%d) has joined the server", Nome[playerid], playerid);
    SendClientMessageToAll(-1, stringa);
    GameTextForPlayer(playerid, "~b~Benvenuto su~n~~g~I~w~L~r~V ~y~SA-MP Server~n~~b~Versione~n~~r~v0.1~n~~b~Ultimo aggiornamento~n~~r~31/07/2011", 7000, 3);    //GAMETEXTFORPLAYER
    }
}
public OnPlayerDisconnect:

Код:
    GetPlayerName(playerid, Nome[playerid], 24);
    switch(reason)
    {
        case 0: format(stringa, sizeof stringa, "%s has left the server (Crash)", Nome[playerid]);
        case 1: format(stringa, sizeof stringa, "%s has left the server", Nome[playerid]);
        case 2:
        {
            format(stringa, sizeof stringa, "%s has left the server (Kicked/Banned)", Nome[playerid]);
            PlayCrimeReportForPlayer(playerid, playerid, 3);
        }
    }
    SendClientMessageToAll(-1, stringa);
Reply
#2

Why in the heck do you use for loop?
Here you go;
Compare these two to yours, and see what's the differences.
pawn Код:
public OnPlayerConenct(playerid) {
    format(stringa, sizeof stringa, "%s (ID:%d) has joined the server", GetPlayerNameEx(playerid), playerid);
    SendClientMessageToAll(-1, stringa);
    GameTextForPlayer(playerid, "~b~Benvenuto su~n~~g~I~w~L~r~V ~y~SA-MP Server~n~~b~Versione~n~~r~v0.1~n~~b~Ultimo aggiornamento~n~~r~31/07/2011", 7000, 3);    //GAMETEXTFORPLAYER
    return 1;
}
pawn Код:
public OnPlayerDisconenct(playerid) {
    switch(reason) {
        case 0: format(stringa, sizeof stringa, "%s has left the server (Crash)", GetPlayerNameEx(playerid));
        case 1: format(stringa, sizeof stringa, "%s has left the server", GetPlayerNameEx(playerid));
        case 2: format(stringa, sizeof stringa, "%s has left the server (Kicked/Banned)", GetPlayerNameEx(playerid));
    }
    SendClientMessageToAll(-1, stringa);
    return 1;
}
This function returns the player his name faster and easier.
pawn Код:
stock GetPlayerNameEx(playerid) {
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    return PlayerName;
}
EDIT: If you are a beginner, that is still good but compare the differences so your knowledge would be higher.
Reply
#3

so these two features I've written are much better and faster?
Reply
#4

Mine is faster, and you used for loop which you don't need.
In mine, it's simple and better because I use a function to get the player his name quickly but as I said compare them and see your mistakes, if you need more help about these two. Just PM me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)