Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Seat Belt V1.0
- =>Created by Castle<=
- Thanks to Harry Gail for the Collision Function
- */
- #include <a_samp>
- #define COLOR_GREY 0xB4B5B7FF
- #define COLOR_PURPLE 0xC2A2DAAA
- #define COLOR_LIGHTRED 0xFF6347AA
- #define INVALID_COLLISION_TIMER_ID -1
- #define COLLISION_TIMER_INTERVAL 100
- #define HPLOSS 3//the amount the player looses health for a collision
- 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];
- public OnFilterScriptInit()
- {
- print("__________________________________________________________________");
- print("| |");
- print("| Seat Belt V1.0 |");
- print("| =>Created by Castle<= |");
- print("| |");
- print("|________________________________________________________________|");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(playerCollisionTimerId[playerid] != INVALID_COLLISION_TIMER_ID)//ensures the timers are killed properly
- {
- KillTimer(playerCollisionTimerId[playerid]);
- playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext,"/seatbelt",true,9)||!strcmp(cmdtext,"/sb",true,3))
- {
- if(MotorBike(GetPlayerVehicleID(playerid))){ return SendClientMessage(playerid,COLOR_GREY,"Bikes don't have seat belts you dummy!"); }
- else if(SeatBelt[playerid]!=1)
- {
- SeatBelt[playerid]=1;
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"buckled his seat belt"); }
- else{ return PlayerActionMessage(playerid,30.0,"buckled her seat belt"); }
- }
- else if(SeatBelt[playerid]!=0)
- {
- SeatBelt[playerid]=0;
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"unbuckled his seat belt"); }
- else{ return PlayerActionMessage(playerid,30.0,"unbuckled her seat belt"); }
- }
- }
- /* if(!strcmp(cmdtext,"/car",true,4)){ new Float:cX, Float:cY, Float:cZ, Float:cA; GetPlayerPos(playerid,Float:cX,Float:cY,Float:cZ); GetPlayerFacingAngle(playerid,Float:cA); new car=CreateVehicle(496,Float:cX,Float:cY,Float:cZ,Float:cA,1,1,999999); return PutPlayerInVehicle(playerid,car,0); }
- if(!strcmp(cmdtext,"/bike",true,5)){ new Float:bX, Float:bY, Float:bZ, Float:bA; GetPlayerPos(playerid,Float:bX,Float:bY,Float:bZ); GetPlayerFacingAngle(playerid,Float:bA); new bike=CreateVehicle(581,Float:bX,Float:bY,Float:bZ,Float:bA,1,1,999999); return PutPlayerInVehicle(playerid,bike,0); }
- if(!strcmp(cmdtext, "/hp", true,3))
- {
- new Float:H;
- GetPlayerHealth(playerid, H);
- new hpMSG[128];
- format(hpMSG, sizeof(hpMSG), "Your HP: %.1f", H);
- SendClientMessage(playerid, COLOR_GREY, hpMSG);
- return 1;
- }*/
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- 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]);// extra security purposes
- new vehicle_id = GetPlayerVehicleID(playerid);
- new Float:vehicle_health;
- GetVehicleHealth(vehicle_id, vehicle_health);
- prevVehicleHealth[playerid] = vehicle_health; // to prevent possible glitches
- // start timer, player is certainly in a vehicle
- playerCollisionTimerId[playerid] = SetTimerEx("PlayerCollisionChecker", COLLISION_TIMER_INTERVAL, true, "ii", playerid, vehicle_id);
- }
- if( (newstate != oldstate) && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) )
- {
- // player is definitely out of vehicle (but was in vehicle previously)
- KillTimer(playerCollisionTimerId[playerid]);
- playerCollisionTimerId[playerid] = INVALID_COLLISION_TIMER_ID;
- SeatBelt[playerid]=0;
- if(Sex(GetPlayerSkin(playerid))){ return PlayerActionMessage(playerid,30.0,"unbuckled his seat belt"); }
- else{ return PlayerActionMessage(playerid,30.0,"unbuckled her seat belt"); }
- }
- 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 OnPlayerCollide(playerid, vehicleid, Float:vehicle_health_loss)
- {
- new Float:pHP;
- if(SeatBelt[playerid]==0)
- {
- GetPlayerHealth(playerid,pHP);
- 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;
- }
- 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
Advertisement