daily pastebin goal
75%
SHARE
TWEET

OnPlayerConnect OnPlayerDisconnect OnPlayerSpawn

a guest Apr 2nd, 2017 14 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public OnPlayerConnect(playerid)
  2. {
  3.     new string[256], ip[64], plname[MAX_PLAYER_NAME];
  4.     GetPlayerName(playerid,plname,sizeof(plname));
  5.     GetPlayerIp(playerid,ip,64);
  6.    
  7.     MAX_PLAYERS_CURRENT = GetPlayerPoolSize();
  8.  
  9.     // Important !
  10.     gPlayerLoad[playerid] = 0;
  11.     gPlayerLogged[playerid] = 0;
  12.     gPlayerLogTries[playerid] = 0;
  13.     gPlayerAccount[playerid] = 0;
  14.     gPlayerSpawned[playerid]=0;
  15.     gPlayerSpawn[playerid] = 1;
  16.     gPlayerInventory[playerid] = 35;
  17.     SetPlayerColor(playerid,0xFFFFFF00);
  18.     PlayAudioStreamForPlayer(playerid,"http://sanandreas-rp.fr/music/intro.mp3");
  19.    
  20.     if(IsPlayerNPC(playerid))
  21.     {
  22.         if(strcmp(ip,"127.0.0.1", true) !=0)
  23.             {Ban(playerid);return 1;}
  24.     }
  25.  
  26.     if (MySQLCheckIPBanned(ip) != 0)
  27.         {MySQLKick(playerid,-1,"IP bannie");return 0;}
  28.  
  29.     if(gServerReboot==1)
  30.     {
  31.         msg_Client(playerid,COLOR_SERVER,"{005660}» Serveur «{C8C8C8} Le serveur est en cours de redémarage.");
  32.         msg_Client(playerid,COLOR_SERVER,"{005660}» Serveur «{C8C8C8} Utilisez '/q' pour quitter.");
  33.         SetTimerEx("TimerKick", 1000, 0, "i", playerid);
  34.         return 0;
  35.     }
  36.  
  37.     ClearChatbox(playerid,10);
  38.     format(string,sizeof(string),"{005660}» Serveur «{C8C8C8} Chargement de %s ... Merci de patientez .",NICK_NAME);
  39.     msg_Client(playerid, COLOR_SERVER, string);
  40.    
  41.     server_DefaultStats(playerid);
  42.  
  43.     if(!IsPlayerNPC(playerid))
  44.     {
  45.         format(string,sizeof(string),"{A98500}» Connexion «{FFFFFF} %s[%d] connecté avec l'ip : {FF0000}%s",plname,playerid,ip);
  46.         msg_Admin(COLOR_LIGHTGREEN,string,3);
  47.         gServerPlayers++;
  48.         format(string,sizeof(string),"%d joueurs",gServerPlayers);
  49.         TextDrawSetString(text_Intro[5],string);
  50.     }
  51.    
  52.     // Texts Draw
  53.     server_ShowIntroTexts(playerid);
  54.     init_PlayerTexts(playerid);
  55.     payday_HideTexts(playerid);
  56.     job_HideTexts(playerid);
  57.    
  58.        
  59.     // Inspection du nom
  60.     if(server_SpecName(plname) == 0 && !IsPlayerNPC(playerid))
  61.     {
  62.         format(string,sizeof(string),"{6E6E6E}» AntiCheat «{AAAAAA} %s a été kické pour nom NO-RP.",plname);
  63.         msg_Admin(COLOR_RED,string,3);
  64.         return MySQLKick(playerid,-1,"Nom Non-RP");
  65.     }
  66.     server_BadNames(playerid);
  67.    
  68.     // Variables
  69.     server_DefaultVariables(playerid);
  70.     FadePlayerConnect(playerid);
  71.  
  72.     // Véhicules
  73.     for(new h = 1; h <=totalVehicles; h++)
  74.         {SetVehicleParamsForPlayer(h,playerid,0,vehicle[h][cLock]);}
  75.    
  76.     // Inscrit ?
  77.     new sqlaccountstatus = MySQLCheckAccount(plname);
  78.     if(sqlaccountstatus != 0)
  79.     {
  80.         if (MySQLCheckAccountLocked(sqlaccountstatus) != 0)
  81.         {
  82.             msg_Client(playerid,COLOR_SERVER,"{005660}» Serveur «{C8C8C8} Votre compte est locké - Veuillez contacter un administrateur.");
  83.             msg_Client(playerid,COLOR_SERVER,"{005660}» Serveur «{C8C8C8} Utilisez '/q' pour quitter.");
  84.             MySQLBan(playerid,-1,"Compte locké",-1);
  85.             return 0;
  86.         }
  87.         gPlayerAccount[playerid] = 1;
  88.         PlayerInfo[playerid][pSQLID]=sqlaccountstatus;
  89.     }
  90.     else
  91.         {gPlayerAccount[playerid] = 0;}
  92.     gPlayerLoad[playerid] = 1;
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerSpawn(playerid)
  97. {
  98.     if(IsPlayerNPC(playerid))
  99.     {
  100.         new npcname[MAX_PLAYER_NAME+1];
  101.         GetPlayerName(playerid, npcname, sizeof(npcname));
  102.         npc_Spawn(playerid,npcname);
  103.         return 1;
  104.     }
  105.     if(inscription_Step[playerid]>=1 && inscription_Step[playerid]<=9 || gPlayerLogged[playerid] != 1)
  106.         {return 1;}
  107.        
  108.     //anticheat_Sobeit2(playerid);
  109.     UpdateStatsTextsPlayers(playerid,1);
  110.     UpdateStatsTextsPlayers(playerid,2);
  111.     UpdateStatsTextsPlayers(playerid,4);
  112.    
  113.     AntiDeAMX();
  114.    
  115.     if(PlayerInfo[playerid][pChar] > 0 && PlayerInfo[playerid][pChar] < 312)
  116.         {SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);}
  117.     else
  118.         {SetPlayerSkin(playerid, 299);}
  119.     SetPlayerColor(playerid,0xFFFFFF00);
  120.     SafeSetPlayerHealth(playerid,100.0);
  121.     SetPlayerSpawn(playerid);
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerDisconnect(playerid, reason)
  126. {
  127.     new astring[256];
  128.     if(gPlayerLogged[playerid] == 0)
  129.         {KillTimer(player_antihack[playerid]); TimerConnectOff(playerid);}
  130.     else
  131.     {
  132.         format(sql, sizeof(sql), "INSERT INTO lvrp_log_disconnect (Date,Ip,SQLid) VALUES (UNIX_TIMESTAMP(),'%s',%d)",PlayerInfo[playerid][pIP], PlayerInfo[playerid][pSQLID]);
  133.         mysql_pquery(MYSQL,sql);
  134.     }
  135.        
  136.     if(IsPlayerNPC(playerid))
  137.     {
  138.         if(IsValidDynamic3DTextLabel(npc_Label[playerid]))
  139.             {DestroyDynamic3DTextLabel(npc_Label[playerid]);}
  140.     }
  141.        
  142.     if(job_Start[playerid]==1)
  143.         {job_End(playerid);}
  144.        
  145.     if(police_PlayerIsRoped[playerid] == true || PlayerInfo[playerid][pMember] > 0 && PlayerInfo[playerid][pMember] < 5)
  146.     {
  147.         for(new i=0; i<50; i++)
  148.         {
  149.             if(IsValidDynamicObject(police_Rope[playerid][i]))
  150.                 {DestroyDynamicObject(police_Rope[playerid][i]);}
  151.         }
  152.     }
  153.        
  154.     if(boomBox[playerid][used] != 0)
  155.     {
  156.         if(IsValidDynamicObject(boombox_Object[playerid]))
  157.             {DestroyDynamicObject(boombox_Object[playerid]);}
  158.         boomBox[playerid][used] =0;
  159.     }
  160.     if(mecano_PhoneId==playerid)
  161.         {mecano_PhoneId=-1;}
  162.     if(taxi_PhoneId==playerid)
  163.         {taxi_PhoneId=-1;}
  164.  
  165.     if(player_CarryBody[playerid] != -1)
  166.         {body_StopCarry(playerid,0);}
  167.        
  168.     if(bag[playerid][statut]==1)
  169.     {
  170.         if(IsValidDynamicObject(bag_Object[playerid]))
  171.             {DestroyDynamicObject(bag_Object[playerid]);}
  172.         if(IsValidDynamic3DTextLabel(bag_Label[playerid]))
  173.             {DestroyDynamic3DTextLabel(bag_Label[playerid]);}
  174.     }
  175.    
  176.     if(basket_Ball[playerid] != -1)
  177.     {
  178.         if(IsValidDynamicObject(basket[basket_Ball[playerid]][object]))
  179.             {DestroyDynamicObject(basket[basket_Ball[playerid]][object]);}
  180.         basket[basket_Ball[playerid]][used]=0; basket_Ball[playerid]=-1;
  181.     }
  182.    
  183.     if(gPlayerFPS[playerid] == true && IsValidObject(fpsObject[playerid]))
  184.         {DestroyObject(fpsObject[playerid]);}
  185.        
  186.     if(car_PlayerInSafe[playerid] != 0)
  187.         {car_InSafe[car_PlayerInSafe[playerid]]=false; car_PlayerInSafe[playerid]=0;}
  188.        
  189.     PlayerInfo[playerid][pConnected]=0;
  190.     RemovePlayerAttachedObject(playerid,BagSlotObject[playerid]);
  191.     FadePlayerDisconnect(playerid);
  192.  
  193.     if(IsValidDynamic3DTextLabel(DutyAdmin[playerid]))
  194.         {DestroyDynamic3DTextLabel(DutyAdmin[playerid]);}
  195.     if(IsValidDynamic3DTextLabel(PME[playerid]))
  196.         {DestroyDynamic3DTextLabel(PME[playerid]);}
  197.     if(IsValidDynamic3DTextLabel(player_ID[playerid]))
  198.         {DestroyDynamic3DTextLabel(player_ID[playerid]);}
  199.     //Delete3DTextLabel(player_ID[playerid]);
  200.     if(IsValidDynamicObject(player_TaxiLicense[playerid]))
  201.         {DestroyDynamicObject(player_TaxiLicense[playerid]);}
  202.        
  203.     if(laser_Statue[playerid]==1)
  204.         {RemovePlayerAttachedObject(playerid,laser_Object[playerid]);}
  205.        
  206.     if(ArmorSlotObject[playerid]!=-1)
  207.         {RemovePlayerAttachedObject(playerid,ArmorSlotObject[playerid]);}
  208.        
  209.     /*for(new i=0; i<5; i++)
  210.     {
  211.         if(PlayerInfo[playerid][pCar][i] != -1 && !IsPlayerNPC(playerid))
  212.             {SetTimerEx("vehicle_DeletePlayer",DELETE_VEHICLE*60000,false,"dd",PlayerInfo[playerid][pSQLID],PlayerInfo[playerid][pCar][i]); }
  213.     }*/
  214.        
  215.     if(reason == 0)
  216.     {
  217.         PlayerInfo[playerid][pCrashed] = 1; PlayerInfo[playerid][pSkinCrash] = GetPlayerSkin(playerid);
  218.         format(astring, sizeof(astring), "> %s(%d) a quitté %s [Crash]",PlayerInfo[playerid][pRealName],playerid,SERVER_NAME);
  219.         if(police_Duty[playerid] == 0)
  220.         {
  221.             for(new slot = 0; slot != 12; slot++)
  222.             {
  223.                 new wep, ammo;
  224.                 GetPlayerWeaponData(playerid, slot, wep, ammo);
  225.                 if(wep != 0 && ammo != 0)
  226.                 {
  227.                     if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
  228.                     else if(PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wep; PlayerInfo[playerid][pAmmo2] = ammo; }
  229.                     else if(PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wep; PlayerInfo[playerid][pAmmo3] = ammo; }
  230.                     else if(PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wep; PlayerInfo[playerid][pAmmo4] = ammo; }
  231.                 }
  232.             }
  233.         }
  234.         else
  235.             {PlayerInfo[playerid][pDutyCrash]=1;}
  236.     }
  237.     else if(reason == 2 && !IsPlayerNPC(playerid))
  238.         {format(astring, sizeof(astring), "> %s(%d) a quitté %s [Kick]",PlayerInfo[playerid][pRealName],playerid,SERVER_NAME);}
  239.     else
  240.         {format(astring, sizeof(astring), "> %s(%d) a quitté %s [Déconnexion]",PlayerInfo[playerid][pRealName],playerid,SERVER_NAME);}
  241.     if(!IsPlayerNPC(playerid))
  242.         {ProxDetector(30.0, playerid, astring, 0xA8AFC8FF, 0xA8AFC8FF, 0xA8AFC8FF, 0xA8AFC8FF, 0xA8AFC8FF,false);}
  243.    
  244.     if(gServerReboot==0)
  245.         {OnPlayerUpdateSQL(playerid);}
  246.        
  247.     if(police_Duty[playerid]==1)
  248.         {Flicservice --; police_Duty[playerid] = 0;}
  249.     if(mecano_Duty[playerid] == 1)
  250.         {mecano_Duty[playerid]=0; Mechanics--;}
  251.     if(taxi_Duty[playerid] != 0)
  252.         {taxi_Duty[playerid]=0; Taximans--;}
  253.        
  254.     if(!IsPlayerNPC(playerid))
  255.         {gServerPlayers--; format(astring,sizeof(astring),"%d joueurs",gServerPlayers); TextDrawSetString(text_Intro[5],astring);}
  256.    
  257.     new caller = Mobile[playerid];
  258.     if(caller != -1)
  259.     {
  260.         if(caller != -1)
  261.         {
  262.             msg_Client(caller,  COLOR_YELLOW, "{8B8B00}» Tel «{FFFFFF} Votre correspondant s'est déconnecté.");
  263.             CellTime[caller] = 0;
  264.             CellTime[playerid] = 0;
  265.             Mobile[caller] = -1;
  266.             phone_Type[caller]=0;
  267.             phone_Show(caller);
  268.             SetPlayerSpecialAction(caller, SPECIAL_ACTION_STOPUSECELLPHONE);
  269.         }
  270.         Mobile[playerid] = -1;
  271.         CellTime[playerid] = 0;
  272.         phone_Hide(playerid);
  273.         phone_Type[playerid]=0;
  274.         phone_Active[playerid]=0;
  275.     }
  276.     if(gPlayerEvent[playerid] != 0)
  277.         {event[parcitipents]--;}
  278.     if(bank_PlayerRob[playerid] == true)
  279.     {
  280.         if(bank_Rob == true)
  281.         {
  282.             RemovePlayerAttachedObject(playerid,9);
  283.             bank_RobMoney[playerid] = 0;
  284.             bank_PlayerRob[playerid] = false;
  285.             bank_RobTime[playerid] = 0;
  286.             format(astring, sizeof(astring), "*** A TOUTES LES UNITES : %s est mort, un sac a été remis à la banque. ! ***",PlayerInfo[playerid][pRealName]);
  287.             msg_Radio(1, TEAM_RADIO_COLOR, astring);
  288.             msg_Radio(3, TEAM_RADIO_COLOR, astring);
  289.             msg_Radio(4, TEAM_RADIO_COLOR, astring);
  290.         }
  291.     }
  292.     for(new i=0; i<MAX_PLAYERS_CURRENT+1; i++)
  293.     {
  294.         if(IsPlayerConnected(i))
  295.         {
  296.             if(Spectate[i] == playerid)
  297.             {
  298.                 server_TogglePlayerSpectating(i, false);
  299.                 WatchingTV[i] = 0;
  300.                 SetPlayerColor(i, 0xFF000000);
  301.                 DutyAdmin[i] = CreateDynamic3DTextLabel("[Admin En Service]",0xFF000099,0,0,0.3,NAME_DISTANCE,i,INVALID_VEHICLE_ID,0,-1,-1,-1,LABEL_STREAM_DISTANCE);
  302.                 SafeSetPlayerPos(i,1514.6956,-1674.7020,14.0469);
  303.                 SafeSetPlayerArmour(i, 200);
  304.                 SafeSetPlayerHealth(i, 200);
  305.                 SetPlayerSkin(i, 217);
  306.                 server_SetPlayerInterior(i, 0);
  307.                 server_SetPlayerVirtualWorld(i, 0);
  308.                 Spectate[i] = -1;
  309.             }
  310.         }
  311.     }
  312.     if(Spectate[playerid] != -1)
  313.         {server_TogglePlayerSpectating(playerid, 0);}
  314.    
  315.     if(HireCar[playerid] != -1) // Véhicule de location
  316.         {vehicle[HireCar[playerid]][cLock]=0; vehicle_Save(HireCar[playerid],0,0); SetVehicleToRespawn(HireCar[playerid]); HireCar[playerid]=-1;}
  317.        
  318.     MAX_PLAYERS_CURRENT = GetPlayerPoolSize();
  319.     PlayerInfo[playerid][pSQLID]=-1;
  320.     return 1;
  321. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top