How to add more cases
#1

How would i got about adding more cases for this, Like i want a case 3 for a server restart and i want it showing a message

pawn Код:
new pname[MAX_PLAYER_NAME], string[128 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  new plrIP[128];
  GetPlayerIp(playerid, plrIP, sizeof(plrIP));
  switch(reason)
  {
    case 0: format(string, sizeof(string), "%s has left the server - %s. (Crashed)", pname, plrIP);
    case 1: format(string, sizeof(string), "%s has left the server - %s. (Leaving)", pname, plrIP);
    case 2: format(string, sizeof(string), "%s has left the server - %s. (Kicked)", pname, plrIP);
  }
I wanna make it so when the server restarts it sets your last know location.
Reply
#2

save a variable in players file, and then read with 'if(...'
Reply
#3

Quote:
Originally Posted by ♂ Antonio_
save a variable in players file, and then read with 'if(...'
This is how i have it, When you crashe you go to your last know location.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{

    if(AdminDuty[playerid] == 1)
    {
      Delete3DTextLabel(td[playerid]);
    }
    if(LStep[playerid] >= 1)
    {
    TakingTest = 0;
    return 1;
    }
  new pname[MAX_PLAYER_NAME], string[128 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  new plrIP[128];
  GetPlayerIp(playerid, plrIP, sizeof(plrIP));
  switch(reason)
  {
    case 0: format(string, sizeof(string), "%s has left the server - %s. (Crashed)", pname, plrIP);
    case 1: format(string, sizeof(string), "%s has left the server - %s. (Leaving)", pname, plrIP);
    case 2: format(string, sizeof(string), "%s has left the server - %s. (Kicked)", pname, plrIP);
    //case 3: format(string, sizeof(string), "%s has left the server - %s. (Restarting Server)", pname, plrIP);
  }
  // ambushit
    InAmbu[playerid] = 0;
    Watching[playerid] = 0;
    Goto[playerid] = 0;
    //-----------------
  Adminmsg(string);
  AdminDuty[playerid] = 0;
    if(PLogged[playerid] == 1)
    {
      if(reason == 0)
      {
        PlayerInfo[playerid][pCrashed] = 1;
//      PlayerInfo[playerid][pCrashed] = 2;
          PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
        PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
          new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        PlayerInfo[playerid][pLeftX] = x;
            PlayerInfo[playerid][pLeftY] = y;
            PlayerInfo[playerid][pLeftZ] = z;
            PlayerInfo[playerid][pLeftInt] = GetPlayerInterior(playerid);
            PlayerInfo[playerid][pLeftW] = GetPlayerVirtualWorld(playerid);
            SaveAccounts(playerid);
            PlayerLocalMessage(playerid,15.0,"has crashed from the server.");
        }
    }
    GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][pGun1], PlayerInfo[playerid][pAmmo1]);
    GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pGun2], PlayerInfo[playerid][pAmmo2]);
    GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][pGun3], PlayerInfo[playerid][pAmmo3]);
    GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][pGun4], PlayerInfo[playerid][pAmmo4]);
    GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][pGun5], PlayerInfo[playerid][pAmmo5]);
    GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][pGun6], PlayerInfo[playerid][pAmmo6]);
    GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][pGun7], PlayerInfo[playerid][pAmmo7]);
    GetPlayerWeaponData(playerid, 8, PlayerInfo[playerid][pGun8], PlayerInfo[playerid][pAmmo8]);
    GetPlayerWeaponData(playerid, 9, PlayerInfo[playerid][pGun9], PlayerInfo[playerid][pAmmo9]);
    GetPlayerWeaponData(playerid, 10, PlayerInfo[playerid][pGun10], PlayerInfo[playerid][pAmmo10]);
    GetPlayerWeaponData(playerid, 11, PlayerInfo[playerid][pGun11], PlayerInfo[playerid][pAmmo11]);
    GetPlayerWeaponData(playerid, 12, PlayerInfo[playerid][pGun12], PlayerInfo[playerid][pAmmo12]);
  GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
  GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
    DeadTimer[playerid] = 0;
    PlayerInfo[playerid][pDead] = 0;
    JustDied[playerid] = 0;
    ResetPlayerWeapons(playerid);
    SetPlayerWantedLevel(playerid, 0);
//  SaveAccounts(playerid);
    return 1;
}
//}
The crash work fine but i can't get a restart working
Reply
#4

Restarting is not a valid disconnection reason, it returns the value of 'Leaving'.
Reply
#5

Quote:
Originally Posted by Grim_
Restarting is not a valid disconnection reason, it returns the value of 'Leaving'.
I couldn't make it a reason?
Reply
#6

No, it'll always return 0 (Leaving) reason.
Reply
#7

Quote:
Originally Posted by Grim_
No, it'll always return 0 (Leaving) reason.
Any idea on how i can make it detect a restart and then set your last location? So you can contiune on where you where before the restart
Reply
#8

Well, before you have the "restart" code, just save their coordinates in a file and re-set them.
Reply
#9

Thanks for the help, I used ongamemodexit and made a variable for playerinfo set new floats for restart spawn and it works perfectley fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)