save string (new left[MAX_PLAYERS];)
#1

how do i save a string....

Код:
#include <a_samp>
new left[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, -1, "%s has left before you.", left[playerid]);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME]
	GetPlayerName(playerid, name, sizeof(name));
	left[playerid] = name;
	return 1;
}
this is wrong, but you get the point, i want to save a string(the payers name).


help = rep+
Reply
#2

pawn Код:
#include <a_samp>

new strLeft[MAX_PLAYERS][MAX_PLAYER_NAME];

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, -1, "%s has left before you.", strLeft[playerid]);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerName(playerid, strLeft[playerid], MAX_PLAYER_NAME);
    return 1;
}
Reply
#3

I don't think he wants the same ID, I think he wants the last player that actually left the server.
Something like this would be more suitable for that kind of situation, sorry if this isn't what you were actually looking for.

pawn Код:
#include <a_samp>

new LastPlayer[MAX_PLAYER_NAME] = " ";

public OnPlayerConnect(playerid)
{
    if(strcmp(LastPlayer, " ", true) != 0)
    {
        new str[85];
        format(str, sizeof(str), "%s was the last person to leave the server before you joined.", LastPlayer);
        SendClientMessage(playerid, -1, str);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    LastPlayer = name;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)