Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define HOLDING(%0) \
- ((newkeys & (%0)) == (%0))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #include <a_npc>
- public OnGameModeInit()
- {
- ConnectNPC("BotCars","BugCars");
- }
- public OnPlayerSpawn(playerid)
- {
- SetBotInPos("BotCars",0.0,0.0,0.0);
- }
- stock SetBotInPos(botname[],Float:x,Float:y,Float:z)
- {
- for(new id = 0; id < 500 ; id ++)
- {
- if(IsPlayerNPC(id))
- {
- new playername[24];
- GetPlayerName(id,playername,24);
- if(!strcmp(playername,botname,true))
- SetPlayerPos(id,x,y,z);
- }
- }
- }
- stock PutBotInVehicle(botname[],vehicleid)
- {
- for(new id = 0; id < 500 ; id ++)
- {
- if(IsPlayerNPC(id))
- {
- new playername[24];
- GetPlayerName(id,playername,24);
- if(!strcmp(playername,botname,true))
- PutPlayerInVehicle(id, vehicleid, 0);
- }
- }
- }
- stock GetCarAimingPlayer(playerid)
- {
- new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2,Float:A;
- GetPlayerPos(playerid, X1, Y1, Z1);
- GetPlayerFacingAngle(playerid, A);
- for(new v = 0; v < 8000; v++)
- {
- GetVehiclePos(v, X2, Y2, Z2);
- new Float:Raius = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
- if(Raius < 100)
- {
- X1 += (Raius * floatsin(-A, degrees));
- Y1 += (Raius * floatcos(-A, degrees));
- Raius = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
- if(Raius < 0.5) return v;
- }
- }
- return -1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new Float:HealthCar,bool:PlayerAtirou;
- if(newkeys & KEY_FIRE || oldkeys & KEY_FIRE && PlayerAtirou == false)
- {
- new mirando = GetCarAimingPlayer(playerid);
- if(mirando != -1)
- {
- PutBotInVehicle("BotCars",mirando);
- GetVehicleHealth(mirando,HealthCar);
- SetVehicleHealth(mirando,HealthCar-13);
- PlayerAtirou = true;
- }
- if(PlayerAtirou == true)
- {
- SetBotInPos("BotCars",0.0,0.0,0.0);
- PlayerAtirou = false;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement