Advertisement
matheusspohr

Public OnPlayerConnect...

Apr 21st, 2015
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. public OnPlayerConnect(playerid)
  2. {
  3. // Always allow NPC's to login without password or account
  4. if (IsPlayerNPC(playerid))
  5. return 1;
  6.  
  7. // Setup local variables
  8. new Name[MAX_PLAYER_NAME], NewPlayerMsg[128], HouseID;
  9.  
  10. // Setup a PVar to allow cross-script money-transfers (only from filterscript to this mainscript) and scorepoints
  11. SetPVarInt(playerid, "PVarMoney", 0);
  12. SetPVarInt(playerid, "PVarScore", 0);
  13.  
  14. // Get the playername
  15. GetPlayerName(playerid, Name, sizeof(Name));
  16. // Also store this name for the player
  17. GetPlayerName(playerid, APlayerData[playerid][PlayerName], 24);
  18.  
  19. // Send a message to all players to let them know somebody else joined the server
  20. format(NewPlayerMsg, 128, TXT_PlayerJoinedServer, Name, playerid);
  21. SendClientMessageToAll(0xFFFFFFFF, NewPlayerMsg);
  22.  
  23. // Try to load the player's datafile ("PlayerFile_Load" returns "1" is the file has been read, "0" when the file cannot be read)
  24. if (PlayerFile_Load(playerid) == 1)
  25. {
  26. // Check if the player is still banned
  27. if (APlayerData[playerid][BanTime] < gettime()) // Player ban-time is passed
  28. ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_INPUT, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
  29. else // Player is still banned
  30. {
  31. ShowRemainingBanTime(playerid); // Show the remaining ban-time to the player is days, hours, minutes, seconds
  32. Kick(playerid); // Kick the player
  33. }
  34. }
  35. else
  36. ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_INPUT, TXT_DialogRegisterTitle, TXT_DialogRegisterMsg, TXT_DialogRegisterButton1, TXT_DialogButtonCancel);
  37.  
  38. // The houses have been loaded but not the cars, so load all vehicles assigned to the player's houses
  39. for (new HouseSlot; HouseSlot < MAX_HOUSESPERPLAYER; HouseSlot++)
  40. {
  41. // Get the HouseID from this slot
  42. HouseID = APlayerData[playerid][Houses][HouseSlot];
  43. // Check if there is a house in this slot
  44. if (HouseID != 0)
  45. HouseFile_Load(HouseID, true); // Load the cars of the house
  46. }
  47.  
  48. // Speedometer setup
  49. Speedometer_Setup(playerid);
  50.  
  51. // MissionText TextDraw setup
  52. APlayerData[playerid][MissionText] = TextDrawCreate(321.0, 430.0, " ");// Setup the missiontext at the bottom of the screen
  53. TextDrawAlignment(APlayerData[playerid][MissionText], 2); // Align the missiontext to the center
  54. TextDrawUseBox(APlayerData[playerid][MissionText], 1); // Set the missiontext to display inside a box
  55. TextDrawBoxColor(APlayerData[playerid][MissionText], 0x00000066); // Set the box color of the missiontext
  56.  
  57. return 1;
  58.  
  59. // Display a message if the player hasn't accepted the rules yet
  60. if(APlayerData[playerid][RulesRead] == false) return SendClientMessage(playerid, 0xFFFFFFFF, "Você Ainda Não Aceitou As Regras...");
  61. return 1;
  62. }
  63.  
  64.  
  65.  
  66. // This function shows the player how long his ban still is when he tries to login (in days, hours, minutes, seconds)
  67. ShowRemainingBanTime(playerid)
  68. {
  69. // Setup local variables
  70. new TotalBanTime, Days, Hours, Minutes, Seconds, Msg[128];
  71.  
  72. // Get the total ban-time
  73. TotalBanTime = APlayerData[playerid][BanTime] - gettime();
  74.  
  75. // Calculate days
  76. if (TotalBanTime >= 86400)
  77. {
  78. Days = TotalBanTime / 86400;
  79. TotalBanTime = TotalBanTime - (Days * 86400);
  80. }
  81. // Calculate hours
  82. if (TotalBanTime >= 3600)
  83. {
  84. Hours = TotalBanTime / 3600;
  85. TotalBanTime = TotalBanTime - (Hours * 3600);
  86. }
  87. // Calculate minutes
  88. if (TotalBanTime >= 60)
  89. {
  90. Minutes = TotalBanTime / 60;
  91. TotalBanTime = TotalBanTime - (Minutes * 60);
  92. }
  93. // Calculate seconds
  94. Seconds = TotalBanTime;
  95.  
  96. // Display the remaining ban-time for this player
  97. SendClientMessage(playerid, 0xFFFFFFFF, TXT_StillBanned);
  98. format(Msg, 128, TXT_BannedDuration, Days, Hours, Minutes, Seconds);
  99. SendClientMessage(playerid, 0xFFFFFFFF, Msg);
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement