SA-MP Forums Archive
save string (new left[MAX_PLAYERS];) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: save string (new left[MAX_PLAYERS];) (/showthread.php?tid=480157)



save string (new left[MAX_PLAYERS];) - ic3cr3am - 09.12.2013

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+


Re: save string (new left[MAX_PLAYERS];) - Dolby - 09.12.2013

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;
}



Re: save string (new left[MAX_PLAYERS];) - Threshold - 09.12.2013

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;
}