SA-MP Forums Archive
Not working :o - 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: Not working :o (/showthread.php?tid=312954)



Not working :o - FireCat - 23.01.2012

When someone disconnects, it only sends everyone a message if the disconnecter is id 0.
Why? -.-
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(PInfo[playerid][Logged] == 1) SaveStats(playerid);
    if(PInfo[playerid][Planting] == 1) DestroyDynamicCP(DrugCP[playerid][0]),PInfo[playerid][Planting] = 0,KillTimer(DrugCP[playerid][1]);
    if(Requester[Requests] != -1) Requester[Requests] = -1, Requests--;
    if(PInfo[playerid][HSeller] != -1) { SendFMessage(PInfo[playerid][HSeller], Yellow, "Your client %s has left the server",GetPName(playerid));}
    if(TrashID[playerid] != -1) RestoreVehicleInfoTD(playerid);
    if(BagID[playerid] != -1) RestoreVehicleInfoTD(playerid);
    switch(reason)
    {
        case 0:SendFMessageToAll(Grey,"%s has left L.A. Noire Cops And Robbers (Crash/Lost Connection)",GetPName(playerid));
        case 1:SendFMessageToAll(Grey,"%s has left L.A. Noire Cops And Robbers (Leaving)",GetPName(playerid));
        case 2:SendFMessageToAll(Grey,"%s has left L.A. Noire Cops And Robbers (Kick/Ban)",GetPName(playerid));
    }



Re: Not working :o - Snowman12 - 23.01.2012

Try formatting the message instead as sometimes when a player leaves the server cannot process the message quick enough to everyone.


Re: Not working :o - Babul - 24.01.2012

the disconnect takes place regardless if the script still runs or not. that means: the playername, if useing GetPlayerName(), will fail due to the player already being DCed.
create an array like PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME]; and save the playername when a player connects. later at disconnect, you can depend on the array containing the right name. since the playerid wont change in the OPDC, you can use it as a pointer to the cell:
pawn Код:
format(string,sizeof(string),"%s",PlayerName[playerid]);
edit: i first had in mind that the GetPlayerName() inside the SendClientMessage also fails, coz its stringlenght(name) is undetermined yet. i always use ready-formatted strings.