KillamanLecce

KSeatbelt v1.0

Aug 4th, 2012
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.04 KB | None | 0 0
  1. /*
  2. ________________________________________________________________________________
  3. Killaman's Script: KSeatbelt
  4. Versione: 1.0
  5. Data di Rilascio: 04/08/2012
  6. ________________________________________________________________________________
  7.                                          Copyright (c) 2012 - Killaman's Script
  8.                                          
  9.                                                ** Informazione:
  10.                                          Tu puoi modificare questo script a tuo
  11.                                          piacimento naturalmente lasciando i cr-
  12.                                          editi.
  13. ________________________________________________________________________________
  14. */
  15. #include <a_samp>
  16.  
  17. #define COLOR_GREY                  0xB4B5B7FF
  18. #define COLOR_PURPLE                0xC2A2DAAA
  19. #define COLOR_DARKRED               0xCD000000
  20. #define INVALID_COLLISION_TIMER_ID  -1
  21. #define COLLISION_TIMER_INTERVAL    100
  22. #define HPLOSS                      3 // Questo è l'ammonto che un player perde con la cintura di sicurezza
  23. #define NOBELT                      25 // Questo è l'ammonto che un player perde senza la cintura di sicurezza
  24.  
  25. forward Sex(playerid);
  26. forward MotorBike(vehicleid);
  27. forward PlayerActionMessage(playerid,Float:radius,message[]);
  28. forward PlayerCollisionChecker(playerid, vehicleid, Float:previous_hp);
  29. forward OnPlayerCollide(playerid, vehicleid, Float:vehicle_health_loss);
  30. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  31.  
  32. new playerCollisionTimerId[MAX_PLAYERS];
  33. new Float:prevVehicleHealth[MAX_PLAYERS];
  34. new SeatBelt[MAX_PLAYERS];
  35. new BigEar[MAX_PLAYERS];
  36.  
  37. LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
  38. {
  39.     ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
  40. }
  41.  
  42. public OnFilterScriptInit()
  43. {
  44.     print("** INFO: Il Filterscript di nome KSeatbelt v1.0 by Killaman è stato Caricato.");
  45.     return 1;
  46. }
  47.  
  48. public OnFilterScriptExit()
  49. {
  50.     return 1;
  51. }
  52.  
  53. public OnPlayerConnect(playerid)
  54. {
  55.     if(playerCollisionTimerId[playerid] != INVALID_COLLISION_TIMER_ID)
  56.     {
  57.         KillTimer(playerCollisionTimerId[playerid]);
  58.         playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
  59.     }
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerCommandText(playerid, cmdtext[])
  64. {
  65.     if(!strcmp(cmdtext,"/cintura",true,9)||!strcmp(cmdtext,"/cin",true,3))
  66.     {
  67.     if(IsPlayerInAnyVehicle(playerid))
  68.         {
  69.         if(MotorBike(GetPlayerVehicleID(playerid))){ return SendClientMessage(playerid,COLOR_GREY,"* Le moto non hanno la cintura di sicurezza."); }
  70.         else if(SeatBelt[playerid]!=1)
  71.         {
  72.             SeatBelt[playerid]=1;
  73.             PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
  74.             if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"allaccia la cintura di sicurezza"); }
  75.             else{ return PlayerActionMessage(playerid,30.0,"allaccia la cintura di sicurezza"); }
  76.         }
  77.         else if(SeatBelt[playerid]!=0)
  78.         {
  79.             SeatBelt[playerid]=0;
  80.             PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
  81.             if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza"); }
  82.             else{ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza"); }
  83.         }
  84.         SendClientMessage(playerid,COLOR_GREY,"Puoi usare questo comando solo su un veicolo.");
  85.         }
  86.     }
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  91. {
  92.     SendClientMessage(playerid,COLOR_DARKRED,"* Digita (/cin)tura per allacciare la cintura di sicurezza.");
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerExitVehicle(playerid, vehicleid)
  97. {
  98.     return 1;
  99. }
  100.  
  101. public OnPlayerStateChange(playerid, newstate, oldstate)
  102. {
  103.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  104.     {
  105.         if(playerCollisionTimerId[playerid] != INVALID_COLLISION_TIMER_ID)
  106.         KillTimer(playerCollisionTimerId[playerid]);
  107.         new vehicle_id = GetPlayerVehicleID(playerid);
  108.         new Float:vehicle_health;
  109.         GetVehicleHealth(vehicle_id, vehicle_health);
  110.         prevVehicleHealth[playerid] = vehicle_health;
  111.         playerCollisionTimerId[playerid] = SetTimerEx("PlayerCollisionChecker", COLLISION_TIMER_INTERVAL, true, "ii", playerid, vehicle_id);
  112.     }
  113.     if( (newstate != oldstate) && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) )
  114.     {
  115.         KillTimer(playerCollisionTimerId[playerid]);
  116.         playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
  117.         SeatBelt[playerid]=0;
  118.         PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
  119.         if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza e scende dal veicolo"); }
  120.         else{ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza e scende dal veicolo"); }
  121.     }
  122.     return 1;
  123. }
  124.  
  125. public PlayerCollisionChecker(playerid, vehicleid)
  126. {
  127.     new Float:newhp;
  128.     GetVehicleHealth(vehicleid, newhp);
  129.  
  130.     if(prevVehicleHealth[playerid] - newhp > 0)
  131.     {
  132.         OnPlayerCollide(playerid, vehicleid, prevVehicleHealth[playerid] - newhp);
  133.     }
  134.     prevVehicleHealth[playerid] = newhp;
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerDeath(playerid, killerid, reason)
  139. {
  140.     SetPlayerDrunkLevel(playerid, 0);
  141.     SeatBelt[playerid]=0;
  142.     return 1;
  143. }
  144.  
  145. public OnPlayerCollide(playerid, vehicleid, Float:vehicle_health_loss)
  146. {
  147.     new Float:pHP;
  148.     if(SeatBelt[playerid]==0)
  149.     {
  150.         GetPlayerHealth(playerid,pHP);
  151.         SeatBelt[playerid]=0;
  152.         PlayerPlaySound(playerid, 1140, 0.0, 0.0, 0.0);
  153.         SendClientMessage(playerid,COLOR_DARKRED,"* Hai preso una botta e non hai la cintura ed ora ti sei fatto un bel volo sfondando il parabrezza.");
  154.         TogglePlayerControllable(playerid, 0);
  155.         RemovePlayerFromVehicle(playerid);
  156.         TogglePlayerControllable(playerid, 1);
  157.         new Float:slx, Float:sly, Float:slz;
  158.         GetPlayerPos(playerid, slx, sly, slz);
  159.         SetPlayerPos(playerid, slx, sly, slz+4);
  160.         SetTimerEx("Fall2", 1000, false, "u", playerid);
  161.         return SetPlayerHealth(playerid,pHP-NOBELT);
  162.     }
  163.     else if(SeatBelt[playerid]==1)
  164.     {
  165.         GetPlayerHealth(playerid,pHP);
  166.         SendClientMessage(playerid,COLOR_DARKRED,"* Hai preso una botta ma perfortuna hai la cintura e quindi sei solo un pò stordito.");
  167.         SetPlayerDrunkLevel(playerid, 5000);
  168.         FreezePlayer(playerid, 4);
  169.         return SetPlayerHealth(playerid,pHP-HPLOSS);
  170.     }
  171.     return 1;
  172. }
  173.  
  174. public Sex(playerid)
  175. {   new pSex = GetPlayerSkin(playerid);
  176.     if( pSex == 0 || pSex == 106 || pSex == 107 || pSex == 102 || pSex == 103 || pSex == 104 || pSex == 114 || pSex == 115 || pSex == 116 || pSex == 108 || pSex == 109 || pSex == 110 || pSex == 121 || pSex == 122 || pSex == 123 || pSex == 173 || pSex == 174 || pSex == 175 || pSex == 117 || pSex == 118 || pSex == 120 || pSex == 100 || pSex == 247 || pSex == 248 || pSex == 254 || pSex == 111 || pSex == 112 || pSex == 113 || pSex == 124 || pSex == 125 || pSex == 126 ||
  177.         pSex == 127 || pSex == 163 || pSex == 164 || pSex == 165 || pSex == 166 || pSex == 274 || pSex == 275 || pSex == 276 || pSex == 277 || pSex == 278 || pSex == 279 || pSex == 280 || pSex == 281 || pSex == 282 || pSex == 283 || pSex == 284 || pSex == 285 || pSex == 286 || pSex == 287 || pSex == 288 || pSex == 146 || pSex == 154 || pSex == 97 || pSex == 45 || pSex == 18 || pSex == 128 || pSex == 132 || pSex == 33 || pSex == 58 || pSex == 59 || pSex == 160 || pSex == 161 ||
  178.         pSex == 162 || pSex == 200 || pSex == 202 || pSex == 32 || pSex == 33 || pSex == 34 || pSex == 258 || pSex == 259 || pSex == 26 || pSex == 51 || pSex == 52 || pSex == 80 || pSex == 81 || pSex == 23 || pSex == 96 || pSex == 99 || pSex == 147 || pSex == 153 || pSex == 167 || pSex == 68 || pSex == 171 || pSex == 176 || pSex == 177 || pSex == 179 || pSex == 187 || pSex == 189 || pSex == 203 || pSex == 204 || pSex == 155 || pSex == 209 || pSex == 217 || pSex == 260 || pSex == 16 ||
  179.         pSex == 27 || pSex == 264 || pSex == 70 || pSex == 134 || pSex == 135 || pSex == 137 || pSex == 181 || pSex == 213 || pSex == 212 || pSex == 230 || pSex == 239 || pSex == 249 || pSex == 241 || pSex == 242 || pSex == 252 || pSex == 253 || pSex == 255 || pSex == 29 || pSex == 30 || pSex == 49 || pSex == 50 || pSex == 57 || pSex == 61 || pSex == 62 || pSex == 66 || pSex == 73 || pSex == 78 || pSex == 78 || pSex == 82 || pSex == 83 || pSex == 84 || pSex == 101 || pSex == 136 || pSex == 14 ||
  180.         pSex == 142 || pSex == 143 || pSex == 144 || pSex == 15 || pSex == 156 || pSex == 168 || pSex == 17 || pSex == 170 || pSex == 180 || pSex == 182 || pSex == 183 || pSex == 184 || pSex == 186 || pSex == 185 || pSex == 188 || pSex == 19 || pSex == 20 || pSex == 206 || pSex == 21 || pSex == 22 || pSex == 210 || pSex == 220 || pSex == 221 || pSex == 222 || pSex == 223 || pSex == 227 || pSex == 228 || pSex == 234 || pSex == 235 || pSex == 236 || pSex == 24 || pSex == 240 || pSex == 25 || pSex == 261 ||
  181.         pSex == 28 || pSex == 35 || pSex == 37 || pSex == 36 || pSex == 44 || pSex == 46 || pSex == 48 || pSex == 47 || pSex == 262 || pSex == 229 || pSex == 58 || pSex == 59 || pSex == 60 || pSex == 67 || pSex == 7 || pSex == 72 || pSex == 94 || pSex == 95 || pSex == 98 || pSex == 265 || pSex == 266 || pSex == 267 || pSex == 269 || pSex == 270 || pSex == 271 || pSex == 272)
  182.     {
  183.         return 1;
  184.     }
  185.     return 0;
  186. }
  187.  
  188. public MotorBike(vehicleid)
  189. {   new pModel=GetVehicleModel(vehicleid);
  190.     if(pModel==581 || pModel==509 || pModel==481 || pModel==462 || pModel==521 || pModel==463 || pModel==510 || pModel==522 || pModel==461 || pModel==448 || pModel==471 || pModel==468 || pModel==586) { return 1; }
  191.     return 0;
  192. }
  193.  
  194. stock GetPlayerNameEx(playerid)
  195. {
  196.     new string[24];
  197.     GetPlayerName(playerid,string,24);
  198.     new str[24];
  199.     strmid(str,string,0,strlen(string),24);
  200.     for(new i = 0; i < MAX_PLAYER_NAME; i++)
  201.     {
  202.         if (str[i] == '_') str[i] = ' ';
  203.     }
  204.     return str;
  205. }
  206.  
  207. forward Unfreeze(playerid);
  208. public Unfreeze(playerid)
  209. {
  210.     TogglePlayerControllable(playerid, 1);
  211.     SendClientMessage(playerid,COLOR_DARKRED,"* INFO: Ti sei ripreso e puoi guidare ma ti gira ancora la testa.");
  212.     return 1;
  213. }
  214. stock FreezePlayer(playerid, time)
  215. {
  216.     SetTimerEx("Unfreeze", time*1000, false, "u", playerid);
  217.     TogglePlayerControllable(playerid, 0);
  218.     return 1;
  219. }
  220. forward Fall(playerid);
  221. public Fall(playerid)
  222. {
  223.     TogglePlayerControllable(playerid, 1);
  224.     SetPlayerDrunkLevel(playerid, 3000);
  225.     SendClientMessage(playerid,COLOR_DARKRED,"* INFO: Sei ancora stordito per il volo e presenti qualche ferita, sarebbe meglio chiamare un medico.");
  226.     return 1;
  227. }
  228. forward Fall2(playerid);
  229. public Fall2(playerid)
  230. {
  231.     TogglePlayerControllable(playerid, 0);
  232.     LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
  233.     SetTimerEx("Fall", 5000, false, "u", playerid);
  234.     return 1;
  235. }
  236.  
  237. public PlayerActionMessage(playerid,Float:radius,message[])
  238. {
  239.     new string[128];
  240.     format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), message);
  241.     ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  242.     return 1;
  243. }
  244.  
  245. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  246. {
  247.     if(IsPlayerConnected(playerid))
  248.     {
  249.         new Float:posx, Float:posy, Float:posz;
  250.         new Float:oldposx, Float:oldposy, Float:oldposz;
  251.         new Float:tempposx, Float:tempposy, Float:tempposz;
  252.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  253.         for(new i = 0; i < MAX_PLAYERS; i++)
  254.         {
  255.             if(IsPlayerConnected(i))
  256.             {
  257.                 if(!BigEar[i])
  258.                 {
  259.                     GetPlayerPos(i, posx, posy, posz);
  260.                     tempposx = (oldposx -posx);
  261.                     tempposy = (oldposy -posy);
  262.                     tempposz = (oldposz -posz);
  263.                     if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  264.                     {
  265.                         if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
  266.                         {
  267.                             SendClientMessage(i, col1, string);
  268.                         }
  269.                     }
  270.                     else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  271.                     {
  272.                         if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
  273.                         {
  274.                             SendClientMessage(i, col2, string);
  275.                         }
  276.                     }
  277.                     else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  278.                     {
  279.                         if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
  280.                         {
  281.                             SendClientMessage(i, col3, string);
  282.                         }
  283.                     }
  284.                     else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  285.                     {
  286.                         if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
  287.                         {
  288.                             SendClientMessage(i, col4, string);
  289.                         }
  290.                     }
  291.                     else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  292.                     {
  293.                         if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
  294.                         {
  295.                             SendClientMessage(i, col5, string);
  296.                         }
  297.                     }
  298.         }
  299.                 else
  300.                 {
  301.                     SendClientMessage(i, col1, string);
  302.                 }
  303.             }
  304.         }
  305.     }
  306.     return 1;
  307. }
Advertisement
Add Comment
Please, Sign In to add comment