Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* By irinel1996.
- GetVehicleColor by RyDeR`
- Keep the credits please.
- (c) 2011-2012
- */
- #include <a_samp>
- #include <GetVehicleColor>
- //----------------------------------[MACROS]-----------------------------------//
- #define MAX_PCambio MAX_PLAYERS*3
- #define INVALID_CPID -1
- #define LABEL_COLOR 0xFF00EBFF
- #define CALLBACK:%0(%1) forward%0(%1); public%0(%1)
- //-----------------------------------[NEWS]------------------------------------//
- enum PicksCmb
- {
- IDPC,
- Type,
- Float:PX,
- Float:PY,
- Float:PZ,
- IDNewCar
- };
- new PickCam[MAX_PCambio][PicksCmb], PickupC, JustUsed[MAX_PLAYERS];
- //-------------------------------[FUNCTIONS]-----------------------------------//
- start_sveh()
- {
- SetTimer("UpdatePos",30,true);
- return 1;
- }
- stock CreateNitroPickup(Float:X, Float:Y, Float:Z, Texto[])
- {
- new IDPCmb = PickupC;
- if(PickupC > MAX_PCambio-1)
- {
- print(">> ERROR: Pickups limit reached!");
- IDPCmb = INVALID_CPID;
- return IDPCmb;
- }
- PickupC++;
- PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][Type] = 1;
- PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
- AddStaticPickup(1010,23,X,Y,Z,-1);
- if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
- return 0;
- }
- stock CreateRepairPickup(Model, Float:X, Float:Y, Float:Z, Texto[]) //Model, recommended = 1248.
- {
- new IDPCmb = PickupC;
- if(PickupC > MAX_PCambio-1)
- {
- print(">> ERROR: Pickups limit reached!");
- IDPCmb = INVALID_CPID;
- return IDPCmb;
- }
- PickupC++;
- PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][Type] = 2;
- PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
- AddStaticPickup(Model,23,X,Y,Z,-1);
- if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
- return 0;
- }
- stock CreateChangeVeh(Model, NewCar, Float:X, Float:Y, Float:Z, Texto[])
- {
- new IDPCmb = PickupC;
- if(PickupC > MAX_PCambio-1)
- {
- print(">> ERROR: Pickups limit reached!");
- IDPCmb = INVALID_CPID;
- return IDPCmb;
- }
- PickupC++; PickCam[IDPCmb][Type] = 0;
- PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][IDNewCar] = NewCar;
- PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
- AddStaticPickup(Model,23,X,Y,Z,-1);
- if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
- return 0;
- }
- ScarMaxPC()
- {
- return PickupC;
- }
- CALLBACK: UpdatePos()
- {
- for(new pcsc = 0; pcsc < ScarMaxPC(); pcsc++)
- {
- if(pcsc != INVALID_CPID)
- {
- ChangeVeh(pcsc);
- }
- }
- }
- CALLBACK: ChangeVeh(IDPCmb)
- {
- for(new i = 0; i <MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInAnyVehicle(i) && JustUsed[i] == 0)
- {
- new vehicleid = GetPlayerVehicleID(i), color1, color2;
- if(IsVehicleInRangeOfPoint(vehicleid,0.8,PickCam[IDPCmb][PX],PickCam[IDPCmb][PY],PickCam[IDPCmb][PZ]))
- {
- PlayerPlaySound(i, 1133, 0.0, 0.0, 0.0);
- if(PickCam[IDPCmb][Type] == 0)
- {
- PlayerPlaySound(i, 1054, 0.0, 0.0, 0.0);
- new Float:Velocidad[3], Float:X, Float:Y, Float:Z, Float:Angulo;
- GetVehiclePos(vehicleid, X,Y,Z); GetVehicleZAngle(vehicleid,Angulo);
- GetVehicleVelocity(vehicleid, Velocidad[0], Velocidad[1], Velocidad[2]);
- GetVehicleColor(vehicleid, color1, color2); DestroyVehicle(vehicleid);
- new NewVeh = CreateVehicle(PickCam[IDPCmb][IDNewCar],X,Y,Z,Angulo,color1,color2,180);
- PutPlayerInVehicle(i,NewVeh,0);
- SetVehicleVelocity(NewVeh, Velocidad[0], Velocidad[1], Velocidad[2]);
- }
- else if(PickCam[IDPCmb][Type] == 1) { AddVehicleComponent(vehicleid, 1010); }
- else if(PickCam[IDPCmb][Type] == 2) { RepairVehicle(vehicleid); }
- JustUsed[i] = 1; SetTimerEx("ReactivarT",900,0,"i",i);
- }
- }
- }
- }
- return 1;
- }
- CALLBACK: ReactivarT(playerid) { JustUsed[playerid] = 0; return 1; }
- IsVehicleInRangeOfPoint(vehicleid, Float:vrange, Float:x, Float:y, Float:z) //I don't know who made this, sorry.
- {
- new Float:oldpos[3], Float:temppos[3];
- GetVehiclePos(vehicleid, oldpos[0], oldpos[1], oldpos[2]);
- temppos[0] = (oldpos[0] -x); temppos[1] = (oldpos[1] -y); temppos[2] = (oldpos[2] -z);
- if(((temppos[0] < vrange) && (temppos[0] > -vrange)) && ((temppos[1] < vrange) && (temppos[1] > -vrange)) && ((temppos[2] < vrange) && (temppos[2] > -vrange)))
- { return 1; }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement