Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ________________________________________________________________________________
- Killaman's Script: KSeatbelt
- Versione: 1.0
- Data di Rilascio: 04/08/2012
- ________________________________________________________________________________
- Copyright (c) 2012 - Killaman's Script
- ** Informazione:
- Tu puoi modificare questo script a tuo
- piacimento naturalmente lasciando i cr-
- editi.
- ________________________________________________________________________________
- */
- #include <a_samp>
- #define COLOR_GREY 0xB4B5B7FF
- #define COLOR_PURPLE 0xC2A2DAAA
- #define COLOR_DARKRED 0xCD000000
- #define INVALID_COLLISION_TIMER_ID -1
- #define COLLISION_TIMER_INTERVAL 100
- #define HPLOSS 3 // Questo è l'ammonto che un player perde con la cintura di sicurezza
- #define NOBELT 25 // Questo è l'ammonto che un player perde senza la cintura di sicurezza
- forward Sex(playerid);
- forward MotorBike(vehicleid);
- forward PlayerActionMessage(playerid,Float:radius,message[]);
- forward PlayerCollisionChecker(playerid, vehicleid, Float:previous_hp);
- forward OnPlayerCollide(playerid, vehicleid, Float:vehicle_health_loss);
- forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
- new playerCollisionTimerId[MAX_PLAYERS];
- new Float:prevVehicleHealth[MAX_PLAYERS];
- new SeatBelt[MAX_PLAYERS];
- new BigEar[MAX_PLAYERS];
- LoopingAnim(playerid,animlib[],animname[], Float:Speed, looping, lockx, locky, lockz, lp)
- {
- ApplyAnimation(playerid, animlib, animname, Speed, looping, lockx, locky, lockz, lp);
- }
- public OnFilterScriptInit()
- {
- print("** INFO: Il Filterscript di nome KSeatbelt v1.0 by Killaman è stato Caricato.");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(playerCollisionTimerId[playerid] != INVALID_COLLISION_TIMER_ID)
- {
- KillTimer(playerCollisionTimerId[playerid]);
- playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext,"/cintura",true,9)||!strcmp(cmdtext,"/cin",true,3))
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(MotorBike(GetPlayerVehicleID(playerid))){ return SendClientMessage(playerid,COLOR_GREY,"* Le moto non hanno la cintura di sicurezza."); }
- else if(SeatBelt[playerid]!=1)
- {
- SeatBelt[playerid]=1;
- PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"allaccia la cintura di sicurezza"); }
- else{ return PlayerActionMessage(playerid,30.0,"allaccia la cintura di sicurezza"); }
- }
- else if(SeatBelt[playerid]!=0)
- {
- SeatBelt[playerid]=0;
- PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza"); }
- else{ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza"); }
- }
- SendClientMessage(playerid,COLOR_GREY,"Puoi usare questo comando solo su un veicolo.");
- }
- }
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- SendClientMessage(playerid,COLOR_DARKRED,"* Digita (/cin)tura per allacciare la cintura di sicurezza.");
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- if(playerCollisionTimerId[playerid] != INVALID_COLLISION_TIMER_ID)
- KillTimer(playerCollisionTimerId[playerid]);
- new vehicle_id = GetPlayerVehicleID(playerid);
- new Float:vehicle_health;
- GetVehicleHealth(vehicle_id, vehicle_health);
- prevVehicleHealth[playerid] = vehicle_health;
- playerCollisionTimerId[playerid] = SetTimerEx("PlayerCollisionChecker", COLLISION_TIMER_INTERVAL, true, "ii", playerid, vehicle_id);
- }
- if( (newstate != oldstate) && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) )
- {
- KillTimer(playerCollisionTimerId[playerid]);
- playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
- SeatBelt[playerid]=0;
- PlayerPlaySound(playerid, 1131, 0.0, 0.0, 0.0);
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza e scende dal veicolo"); }
- else{ return PlayerActionMessage(playerid,30.0,"slaccia la cintura di sicurezza e scende dal veicolo"); }
- }
- return 1;
- }
- public PlayerCollisionChecker(playerid, vehicleid)
- {
- new Float:newhp;
- GetVehicleHealth(vehicleid, newhp);
- if(prevVehicleHealth[playerid] - newhp > 0)
- {
- OnPlayerCollide(playerid, vehicleid, prevVehicleHealth[playerid] - newhp);
- }
- prevVehicleHealth[playerid] = newhp;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- SetPlayerDrunkLevel(playerid, 0);
- SeatBelt[playerid]=0;
- return 1;
- }
- public OnPlayerCollide(playerid, vehicleid, Float:vehicle_health_loss)
- {
- new Float:pHP;
- if(SeatBelt[playerid]==0)
- {
- GetPlayerHealth(playerid,pHP);
- SeatBelt[playerid]=0;
- PlayerPlaySound(playerid, 1140, 0.0, 0.0, 0.0);
- SendClientMessage(playerid,COLOR_DARKRED,"* Hai preso una botta e non hai la cintura ed ora ti sei fatto un bel volo sfondando il parabrezza.");
- TogglePlayerControllable(playerid, 0);
- RemovePlayerFromVehicle(playerid);
- TogglePlayerControllable(playerid, 1);
- new Float:slx, Float:sly, Float:slz;
- GetPlayerPos(playerid, slx, sly, slz);
- SetPlayerPos(playerid, slx, sly, slz+4);
- SetTimerEx("Fall2", 1000, false, "u", playerid);
- return SetPlayerHealth(playerid,pHP-NOBELT);
- }
- else if(SeatBelt[playerid]==1)
- {
- GetPlayerHealth(playerid,pHP);
- SendClientMessage(playerid,COLOR_DARKRED,"* Hai preso una botta ma perfortuna hai la cintura e quindi sei solo un pò stordito.");
- SetPlayerDrunkLevel(playerid, 5000);
- FreezePlayer(playerid, 4);
- return SetPlayerHealth(playerid,pHP-HPLOSS);
- }
- return 1;
- }
- public Sex(playerid)
- { new pSex = GetPlayerSkin(playerid);
- 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 ||
- 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 ||
- 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 ||
- 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 ||
- 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 ||
- 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)
- {
- return 1;
- }
- return 0;
- }
- public MotorBike(vehicleid)
- { new pModel=GetVehicleModel(vehicleid);
- 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; }
- return 0;
- }
- stock GetPlayerNameEx(playerid)
- {
- new string[24];
- GetPlayerName(playerid,string,24);
- new str[24];
- strmid(str,string,0,strlen(string),24);
- for(new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if (str[i] == '_') str[i] = ' ';
- }
- return str;
- }
- forward Unfreeze(playerid);
- public Unfreeze(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- SendClientMessage(playerid,COLOR_DARKRED,"* INFO: Ti sei ripreso e puoi guidare ma ti gira ancora la testa.");
- return 1;
- }
- stock FreezePlayer(playerid, time)
- {
- SetTimerEx("Unfreeze", time*1000, false, "u", playerid);
- TogglePlayerControllable(playerid, 0);
- return 1;
- }
- forward Fall(playerid);
- public Fall(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- SetPlayerDrunkLevel(playerid, 3000);
- SendClientMessage(playerid,COLOR_DARKRED,"* INFO: Sei ancora stordito per il volo e presenti qualche ferita, sarebbe meglio chiamare un medico.");
- return 1;
- }
- forward Fall2(playerid);
- public Fall2(playerid)
- {
- TogglePlayerControllable(playerid, 0);
- LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
- SetTimerEx("Fall", 5000, false, "u", playerid);
- return 1;
- }
- public PlayerActionMessage(playerid,Float:radius,message[])
- {
- new string[128];
- format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), message);
- ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- return 1;
- }
- public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(!BigEar[i])
- {
- GetPlayerPos(i, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
- {
- SendClientMessage(i, col1, string);
- }
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
- {
- SendClientMessage(i, col2, string);
- }
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
- {
- SendClientMessage(i, col3, string);
- }
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
- {
- SendClientMessage(i, col4, string);
- }
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
- {
- SendClientMessage(i, col5, string);
- }
- }
- }
- else
- {
- SendClientMessage(i, col1, string);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment