Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
- {
- static bool:PressingUse[MAXPLAYERS + 1];
- static bool:DuckBuffer[MAXPLAYERS + 1];
- if (buttons & IN_USE)
- {
- if (!PressingUse[client])
- {
- if (GetEntPropEnt(client, Prop_Send, "m_hVehicle") != -1)
- {
- LeaveVehicle(client);
- buttons &= ~IN_USE;
- PressingUse[client] = true;
- return Plugin_Handled;
- }
- else
- {
- decl Ent;
- Ent = GetClientAimTarget(client, false);
- if (IsValidEdict(Ent))
- {
- decl String:ClassName[255];
- GetEdictClassname(Ent, ClassName, 255);
- //Valid:
- if (StrEqual(ClassName, "prop_vehicle_driveable", false))
- {
- new Float:origin[3];
- new Float:car_origin[3];
- new Float:distance;
- GetClientAbsOrigin(client, origin);
- GetEntPropVector(Ent, Prop_Send, "m_vecOrigin", car_origin);
- distance = GetVectorDistance(origin, car_origin, false);
- if ((distance <= 72.00) && (!GetEntProp(Ent, Prop_Data, "m_bLocked")))
- // It is a car. See if it is locked or not, and if it is in range.
- if ((!GetEntProp(Ent, Prop_Data, "m_bLocked")) && (distance <= 64.00))
- {
- // Car in range, unlocked.
- new Driver = GetEntPropEnt(Ent, Prop_Send, "m_hPlayer");
- if (Driver == -1)
- {
- // AcceptEntityInput(Ent, "use", client);
- // buttons &= ~IN_USE;
- PressingUse[client] = true;
- return Plugin_Handled;
- }
- else if (cars_seats[Ent] > 0)
- {
- // Car has multiple seats, someone already driving
- new Passenger = -1;
- for ( new ic = 1; ic < cars_seats[Ent] + 1; ic++ )
- {
- // Is there a passenger in one of the seats?
- Passenger = GetEntPropEnt(cars_seat_entities[Ent][ic], Prop_Send, "m_hPlayer");
- if (Passenger == -1)
- {
- new chair = cars_seat_entities[Ent][ic];
- if (IsValidEntity(chair))
- {
- new t = cars_type[Ent];
- SetVariantString("");
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- AcceptEntityInput(chair, "use", client);
- new String:car_name2[128];
- GetTargetName(Ent,car_name2,sizeof(car_name2));
- SetVariantString(car_name2);
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- SetVariantString(car_passenger_attachment[t][ic]);
- AcceptEntityInput(chair, "SetParentAttachment", chair, chair, 0);
- break;
- }
- }
- }
- }
- }
- else
- {
- EmitSoundToAll("doors/default_locked.wav", Ent, SNDCHAN_AUTO, SNDLEVEL_NORMAL);
- }
- }
- }
- }
- }
- PressingUse[client] = true;
- }
- else
- {
- PressingUse[client] = false;
- }
- if (buttons & IN_DUCK)
- {
- if (!DuckBuffer[client])
- {
- new car = GetEntPropEnt(client, Prop_Send, "m_hVehicle");
- if (car != -1)
- {
- ViewToggle(car, client);
- }
- }
- DuckBuffer[client] = true;
- }
- else
- {
- DuckBuffer[client] = false;
- }
- return Plugin_Continue;
- }
- public OnThink(entity)
- {
- new Driver = GetEntPropEnt(entity, Prop_Send, "m_hPlayer");
- decl Float:ang[3];
- /* GetEntPropVector(entity, Prop_Data, "m_angRotation", ang);
- new Float:roll = ang[2];
- if(roll > 100.0 || roll < -100.0)
- {
- if (Driver > 0)
- {
- if(IsClientInGame(Driver) && IsPlayerAlive(Driver))
- {
- LeaveVehicle(Driver);
- FakeClientCommand(Driver, "kill");
- }
- }
- } */
- if (IsValidEntity(ViewEnt[entity]))
- {
- if (Driver > 0)
- {
- if(IsClientInGame(Driver) && IsPlayerAlive(Driver))
- {
- SetEntProp(entity, Prop_Data, "m_nNextThinkTick", 1);
- SetEntPropFloat(entity, Prop_Data, "m_flTurnOffKeepUpright", 1.0);
- SetClientViewEntity(Driver, ViewEnt[entity]);
- Driving[Driver] = true;
- new t = cars_type[entity];
- if (car_driver_view[t] == 1)
- {
- if (Cars_Driver_Prop[entity] == -1)
- {
- new prop = CreateEntityByName("prop_physics_override");
- if(IsValidEntity(prop))
- {
- new String:model[128];
- GetClientModel(Driver, model, sizeof(model));
- DispatchKeyValue(prop, "model", model);
- DispatchKeyValue(prop, "skin","0");
- ActivateEntity(prop);
- DispatchSpawn(prop);
- new enteffects = GetEntProp(prop, Prop_Send, "m_fEffects");
- enteffects |= 1;
- enteffects |= 128;
- enteffects |= 512;
- SetEntProp(prop, Prop_Send, "m_fEffects", enteffects);
- new String:car_ent_name[128];
- GetTargetName(entity,car_ent_name,sizeof(car_ent_name));
- SetVariantString(car_ent_name);
- AcceptEntityInput(prop, "SetParent", prop, prop, 0);
- SetVariantString("vehicle_driver_eyes");
- AcceptEntityInput(prop, "SetParentAttachment", prop, prop, 0);
- Cars_Driver_Prop[entity] = prop;
- }
- }
- }
- else Cars_Driver_Prop[entity] = -1;
- }
- }
- }
- if (GetEntProp(entity, Prop_Send, "m_bEnterAnimOn") == 1)
- {
- for (new client = 1; client <= MaxClients; client++)
- {
- if (IsClientInGame(client) && IsPlayerAlive(client))
- {
- if (client != Driver)
- {
- TeleportEntity(client, NULL_VECTOR, CurrentEyeAngle[client], NULL_VECTOR);
- }
- }
- }
- SetEntProp(entity, Prop_Send, "m_nSequence", 0);
- CarHorn[Driver] = false;
- armour[Driver] = GetEntProp(Driver, Prop_Send, "m_ArmorValue");
- SetEntProp(entity, Prop_Send, "m_bEnterAnimOn", 0);
- SetEntProp(entity, Prop_Send, "m_nSequence", 0);
- if (is_chair[entity] <= 1)
- {
- if (GetConVarInt(g_Cvar_GasUse))
- {
- if (car_fuel[entity] > 0.0)
- {
- AcceptEntityInput(entity, "TurnOn");
- }
- else PrintToChat(Driver, "\x04[Car] %T", "No_Gas", Driver);
- }
- else
- {
- AcceptEntityInput(entity, "TurnOn");
- CarOn[entity] = true;
- }
- }
- else if (is_chair[entity] == 2)
- {
- AcceptEntityInput(entity, "TurnOff");
- CarOn[entity] = false;
- }
- decl String:targetName[100];
- decl Float:sprite_rgb[3];
- sprite_rgb[0] = 0.0;
- sprite_rgb[1] = 0.0;
- sprite_rgb[2] = 0.0;
- GetTargetName(entity, targetName, sizeof(targetName));
- new sprite = CreateEntityByName("env_sprite");
- DispatchKeyValue(sprite, "model", "materials/sprites/dot.vmt");
- DispatchKeyValue(sprite, "renderamt", "0");
- DispatchKeyValue(sprite, "renderamt", "0");
- DispatchKeyValueVector(sprite, "rendercolor", sprite_rgb);
- DispatchSpawn(sprite);
- new Float:vec[3];
- GetClientAbsOrigin(Driver, vec);
- GetClientAbsAngles(Driver, ang);
- TeleportEntity(sprite, vec, ang, NULL_VECTOR);
- SetClientViewEntity(Driver, sprite);
- SetVariantString("!activator");
- AcceptEntityInput(sprite, "SetParent", Driver);
- SetVariantString(targetName);
- AcceptEntityInput(Driver, "SetParent");
- SetVariantString("vehicle_driver_eyes");
- AcceptEntityInput(Driver, "SetParentAttachment");
- // SetEntProp(entity, Prop_Send, "m_nSolidType", 2);
- ViewEnt[entity] = sprite;
- }
- if (Driver > 0)
- {
- drivers_car[Driver] = entity;
- Driving[Driver] = true;
- buttons2 = GetClientButtons(Driver);
- // Brake Lights on or Off
- if (buttons2 & IN_ATTACK)
- {
- if (!CarHorn[Driver])
- {
- if (is_chair[entity] <= 1)
- {
- EmitSoundToAll("vehicles/mustang_horn.mp3", entity, SNDCHAN_AUTO, SNDLEVEL_AIRCRAFT);
- CarHorn[Driver] = true;
- new Float:delay = GetConVarFloat(g_Cvar_DelayH);
- h_horn = CreateTimer(delay, Horn_Time, Driver);
- }
- }
- }
- new car_index = g_CarIndex[entity];
- new max = g_CarLightQuantity[car_index];
- if (max > 0)
- {
- decl light;
- if (CarOn[entity])
- {
- light = g_CarLights[car_index][2];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "ShowSprite");
- }
- light = g_CarLights[car_index][3];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "ShowSprite");
- }
- /* AcceptEntityInput(g_CarLights[car_index][6], "LightOn");
- AcceptEntityInput(g_CarLights[car_index][7], "LightOn"); */
- }
- if (buttons2 & IN_JUMP)
- {
- light = g_CarLights[car_index][0];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "ShowSprite");
- }
- light = g_CarLights[car_index][1];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "ShowSprite");
- }
- }
- else
- {
- light = g_CarLights[car_index][0];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "HideSprite");
- }
- light = g_CarLights[car_index][1];
- if (IsValidEntity(light))
- {
- AcceptEntityInput(light, "HideSprite");
- }
- }
- }
- if (GetConVarInt(g_Cvar_GasUse))
- {
- // Car is on so they're burning gas
- // How fast they burn it depends on forewards or reverse or idle
- if (buttons2 & IN_FORWARD)
- {
- car_fuel[entity] -= (0.001 / mpg[entity]);
- }
- else if (buttons2 & IN_BACK)
- {
- car_fuel[entity] -= (0.0005 / mpg[entity]);
- }
- else car_fuel[entity] -= (0.0001 / mpg[entity]);
- if (car_fuel[entity] <= 0.0)
- {
- car_fuel[entity] = 0.0;
- AcceptEntityInput(entity, "TurnOff");
- }
- fuel_display[entity] = RoundToCeil(car_fuel[entity]);
- SetEntData(Driver, m_ArmorValue,fuel_display[entity],4,true);
- }
- if (is_chair[entity] == 0)
- {
- new speed = GetEntProp(entity, Prop_Data, "m_nSpeed");
- PrintHintText(Driver, "%T", "Speed", Driver, speed);
- }
- }
- }
- public Action:Event_player_hurt(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new victimId = GetEventInt(event, "userid");
- if (victimId != 0)
- {
- new victim = GetClientOfUserId(victimId);
- new car = GetEntPropEnt(victim, Prop_Send, "m_hVehicle");
- if (car != -1)
- {
- new plyr_hp = GetClientHealth(victim);
- new damage = GetEventInt(event, "dmg_health");
- plyr_hp -= damage;
- if (plyr_hp <= 0)
- {
- LeaveVehicle(victim);
- FakeClientCommand(victim, "kill");
- }
- else
- {
- SetEntityHealth(victim, plyr_hp);
- }
- if ((cars_seats[car] > 0) && (is_chair[car] == 0))
- {
- new Passenger = -1;
- for ( new ic = 1; ic < cars_seats[car] + 1; ic++ )
- {
- Passenger = GetEntPropEnt(cars_seat_entities[car][ic], Prop_Send, "m_hPlayer");
- if (Passenger > 0)
- {
- plyr_hp = GetClientHealth(Passenger);
- plyr_hp -= damage;
- if (plyr_hp <= 0)
- {
- LeaveVehicle(Passenger);
- FakeClientCommand(Passenger, "kill");
- }
- else
- {
- SetEntityHealth(Passenger, plyr_hp);
- }
- }
- }
- }
- return Plugin_Continue;
- }
- }
- return Plugin_Continue;
- }
- public Action:Car_Seat(client, args)
- {
- if (GetConVarInt(g_Cvar_Enable))
- {
- if (IsPlayerAlive(client))
- {
- new car = GetEntPropEnt(client, Prop_Send, "m_hVehicle");
- if(car != -1)
- {
- if (is_chair[car] == 1)
- {
- new seat = car;
- car = chairs_car[seat];
- new done = 0;
- new Passenger = -1;
- for ( new ic = 1; ic < cars_seats[car] + 1; ic++ )
- {
- Passenger = GetEntPropEnt(cars_seat_entities[car][ic], Prop_Send, "m_hPlayer");
- if (Passenger == -1)
- {
- new chair = cars_seat_entities[car][ic];
- if (IsValidEntity(chair))
- {
- LeaveVehicle(client);
- new t = cars_type[car];
- SetVariantString("");
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- AcceptEntityInput(chair, "use", client);
- new String:car_name2[128];
- GetTargetName(car,car_name2,sizeof(car_name2));
- SetVariantString(car_name2);
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- SetVariantString(car_passenger_attachment[t][ic]);
- AcceptEntityInput(chair, "SetParentAttachment", chair, chair, 0);
- done = 1;
- break;
- }
- }
- }
- new driver = GetEntPropEnt(car, Prop_Send, "m_hPlayer");
- if ((done == 0) && (driver == -1))
- {
- LeaveVehicle(client);
- AcceptEntityInput(car, "use", client);
- done = 1;
- }
- }
- else if (cars_seats[car] > 0)
- {
- new done = 0;
- new Passenger = -1;
- for ( new ic = 1; ic < cars_seats[car] + 1; ic++ )
- {
- if (IsValidEntity(cars_seat_entities[car][ic]))
- {
- Passenger = GetEntPropEnt(cars_seat_entities[car][ic], Prop_Send, "m_hPlayer");
- if (Passenger == -1)
- {
- new chair = cars_seat_entities[car][ic];
- if (IsValidEntity(chair))
- {
- LeaveVehicle(client);
- new t = cars_type[car];
- SetVariantString("");
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- AcceptEntityInput(chair, "use", client);
- new String:car_name2[128];
- GetTargetName(car,car_name2,sizeof(car_name2));
- SetVariantString(car_name2);
- AcceptEntityInput(chair, "SetParent", chair, chair, 0);
- SetVariantString(car_passenger_attachment[t][ic]);
- AcceptEntityInput(chair, "SetParentAttachment", chair, chair, 0);
- done = 1;
- break;
- }
- }
- }
- }
- new driver = GetEntPropEnt(car, Prop_Send, "m_hPlayer");
- if ((done == 0) && (driver == -1))
- {
- AcceptEntityInput(car, "use", client);
- done = 1;
- }
- }
- }
- else PrintToChat(client, "\x04[Car] %T", "Get_Inside", client);
- return Plugin_Handled;
- }
- else PrintToChat(client, "\x04[Car] %T", "Youre_Dead", client);
- return Plugin_Handled;
- }
- else PrintToChat(client, "\x04[Car] %T", "Disabled", client);
- return Plugin_Handled;
- }
- // This spawns the car. At the end is seat information.
- if (StrEqual(info,"1"))
- {
- if (!IsPlayerAlive(param1))
- {
- PrintToChat(param1, "\x04[Car] %T", "Youre_Dead", param1);
- Reset_Car_Selection(param1);
- return;
- }
- if (selected_car[param1] == -1)
- {
- Reset_Car_Selection(param1);
- return;
- }
- if (selected_car_stowed[param1] == 0)
- {
- Reset_Car_Selection(param1);
- return;
- }
- new i = selected_car_type[param1];
- if (i == 0)
- {
- Reset_Car_Selection(param1);
- return;
- }
- if (StrEqual(car_model[i],"FUCK_YOU"))
- {
- PrintToServer("[Car DEBUG] Error in cars.ini for vehicle: %s (Model not found.)", car_name[i]);
- PrintToChat(param1, "\x04[Car DEBUG] %T", "Error_V", param1, car_name[i]);
- PrintToChat(param1, "\x04[Car DEBUG] %T", "Error_No_Spawn", param1);
- Reset_Car_Selection(param1);
- return;
- }
- if (StrEqual(car_script[i],"FUCK_YOU"))
- {
- PrintToServer("[Car DEBUG] Error in cars.ini for vehicle: %s (Script not found.)", car_name[i]);
- PrintToChat(param1, "\x04[Car DEBUG] %T", "Error_V", param1, car_name[i]);
- PrintToChat(param1, "\x04[Car DEBUG] %T", "Error_No_Spawn", param1);
- Reset_Car_Selection(param1);
- return;
- }
- selected_car_stowed[param1] = 0;
- // Get the location for the car.
- new Float:EyeAng[3];
- GetClientEyeAngles(param1, EyeAng);
- new Float:ForwardVec[3];
- GetAngleVectors(EyeAng, ForwardVec, NULL_VECTOR, NULL_VECTOR);
- ScaleVector(ForwardVec, 100.0);
- ForwardVec[2] = 0.0;
- new Float:EyePos[3];
- GetClientEyePosition(param1, EyePos);
- new Float:AbsAngle[3];
- GetClientAbsAngles(param1, AbsAngle);
- new Float:SpawnAngles[3];
- SpawnAngles[1] = EyeAng[1];
- new Float:SpawnOrigin[3];
- AddVectors(EyePos, ForwardVec, SpawnOrigin);
- new ent = CreateEntityByName("prop_vehicle_driveable");
- if(IsValidEntity(ent))
- {
- Cars_Driver_Prop[ent] = -1;
- ActivateEntity(ent);
- decl String:skin[4];
- Format(skin, sizeof(skin), "%i", selected_car_skin[param1]);
- new String:ent_name[16], String:light_index[16];
- Format(ent_name, 16, "%i", ent);
- Format(light_index, 16, "%iLgt", ent);
- g_SpawnedCars[param1] += 1;
- new String:Car_Name[64];
- Format(Car_Name, sizeof(Car_Name), "%s_%i", authid[param1], g_SpawnedCars[param1]);
- DispatchKeyValue(ent, "vehiclescript", car_script[i]);
- DispatchKeyValue(ent, "model", car_model[i]);
- DispatchKeyValueFloat (ent, "MaxPitch", 360.00);
- DispatchKeyValueFloat (ent, "MinPitch", -360.00);
- DispatchKeyValueFloat (ent, "MaxYaw", 90.00);
- DispatchKeyValue(ent, "targetname", Car_Name);
- DispatchKeyValue(ent, "solid","6");
- DispatchKeyValue(ent, "actionScale","1");
- DispatchKeyValue(ent, "EnableGun","0");
- DispatchKeyValue(ent, "ignorenormals","0");
- DispatchKeyValue(ent, "fadescale","1");
- DispatchKeyValue(ent, "fademindist","-1");
- DispatchKeyValue(ent, "VehicleLocked","0");
- DispatchKeyValue(ent, "screenspacefade","0");
- DispatchKeyValue(ent, "spawnflags", "256" );
- DispatchKeyValue(ent, "skin", skin);
- DispatchKeyValue(ent, "setbodygroup", "511" );
- TeleportEntity(ent, SpawnOrigin, SpawnAngles, NULL_VECTOR);
- PrintToServer("[Car] %s spawned a %s.", authid[param1], car_name[i]);
- PrintToChat(param1, "\x04[Car] %T", "Spawn", param1, car_name[i]);
- DispatchSpawn(ent);
- // Thanks to blodia for this
- SetEntProp(ent, Prop_Data, "m_nNextThinkTick", -1);
- SDKHook(ent, SDKHook_Think, OnThink);
- ViewEnt[ent] = -1;
- SetCarOwnership(param1, ent, 1);
- car_owner[ent] = param1;
- new c = selected_car[param1];
- Car_Entity[param1][c] = ent;
- g_CarQty += 1;
- g_CarIndex[ent] = g_CarQty;
- new car_index2 = g_CarIndex[ent];
- g_CarLightQuantity[car_index2] = 0;
- // Set the gas in the tank.
- car_fuel[ent] = selected_car_fuel[param1];
- mpg[ent] = car_mpg[i];
- cars_type[ent] = i;
- CarOn[ent] = true;
- cars_index[ent] = selected_car_index[param1];
- is_chair[ent] = 0;
- chairs_car[ent] = -1;
- // Car is spawned and all neccessary arrays are taken care of.
- // Now we move on to lights.
- if (car_lights[i] == 1)
- {
- // First declare some angles and colours.
- decl Float:brake_rgb[3], Float:brake_angles[3], Float:white_rgb[3], Float:blue_rgb[3];
- brake_rgb[0] = 255.0;
- brake_rgb[1] = 0.0;
- brake_rgb[2] = 0.0;
- blue_rgb[0] = 0.0;
- blue_rgb[1] = 0.0;
- blue_rgb[2] = 255.0;
- white_rgb[0] = 255.0;
- white_rgb[1] = 255.0;
- white_rgb[2] = 255.0;
- brake_angles[0] = 0.0;
- brake_angles[1] = 0.0;
- brake_angles[2] = 0.0;
- // Then we create the brake lights. Siren lights will come later if applicable.
- new brake_l = CreateEntityByName("env_sprite");
- DispatchKeyValue(brake_l, "parentname", ent_name);
- DispatchKeyValue(brake_l, "targetname", light_index);
- DispatchKeyValueFloat(brake_l, "HDRColorScale", 1.0);
- DispatchKeyValue(brake_l, "renderamt", "155");
- DispatchKeyValueVector(brake_l, "rendercolor", brake_rgb);
- DispatchKeyValueVector(brake_l, "angles", brake_angles);
- DispatchKeyValue(brake_l, "spawnflags", "3");
- DispatchKeyValue(brake_l, "rendermode", "5");
- DispatchKeyValue(brake_l, "model", "sprites/light_glow02.spr");
- DispatchKeyValueFloat(brake_l, "scale", 0.2);
- DispatchSpawn(brake_l);
- TeleportEntity(brake_l, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(brake_l, "SetParent", brake_l, brake_l, 0);
- SetVariantString("light_rl")
- AcceptEntityInput(brake_l, "SetParentAttachment", brake_l, brake_l, 0);
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][0] = brake_l;
- new brake_r = CreateEntityByName("env_sprite");
- DispatchKeyValue(brake_l, "parentname", ent_name);
- DispatchKeyValue(brake_l, "targetname", light_index);
- DispatchKeyValueFloat(brake_r, "HDRColorScale", 1.0);
- DispatchKeyValue(brake_r, "renderamt", "155");
- DispatchKeyValueVector(brake_r, "rendercolor", brake_rgb);
- DispatchKeyValueVector(brake_r, "angles", brake_angles);
- DispatchKeyValue(brake_r, "spawnflags", "3");
- DispatchKeyValue(brake_r, "rendermode", "5");
- DispatchKeyValue(brake_r, "model", "sprites/light_glow02.spr");
- DispatchKeyValueFloat(brake_r, "scale", 0.2);
- DispatchSpawn(brake_r);
- TeleportEntity(brake_r, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(brake_r, "SetParent", brake_r, brake_r, 0);
- SetVariantString("light_rr")
- AcceptEntityInput(brake_r, "SetParentAttachment", brake_r, brake_r, 0);
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][1] = brake_r;
- new brake_l2 = CreateEntityByName("env_sprite");
- DispatchKeyValue(brake_l2, "parentname", ent_name);
- DispatchKeyValue(brake_l2, "targetname", light_index);
- DispatchKeyValueFloat(brake_l2, "HDRColorScale", 1.0);
- DispatchKeyValue(brake_l2, "renderamt", "100");
- DispatchKeyValueVector(brake_l2, "rendercolor", brake_rgb);
- DispatchKeyValueVector(brake_l2, "angles", brake_angles);
- DispatchKeyValue(brake_l2, "spawnflags", "3");
- DispatchKeyValue(brake_l2, "rendermode", "5");
- DispatchKeyValue(brake_l2, "model", "sprites/light_glow02.spr");
- DispatchKeyValueFloat(brake_l2, "scale", 0.2);
- DispatchSpawn(brake_l2);
- TeleportEntity(brake_l2, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(brake_l2, "SetParent", brake_l, brake_l, 0);
- SetVariantString("light_rl")
- AcceptEntityInput(brake_l2, "SetParentAttachment", brake_l, brake_l, 0);
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][2] = brake_l2;
- new brake_r2 = CreateEntityByName("env_sprite");
- DispatchKeyValue(brake_r2, "parentname", ent_name);
- DispatchKeyValue(brake_r2, "targetname", light_index);
- DispatchKeyValueFloat(brake_r2, "HDRColorScale", 1.0);
- DispatchKeyValue(brake_r2, "renderamt", "100");
- DispatchKeyValueVector(brake_r2, "rendercolor", brake_rgb);
- DispatchKeyValueVector(brake_r2, "angles", brake_angles);
- DispatchKeyValue(brake_r2, "spawnflags", "3");
- DispatchKeyValue(brake_r2, "rendermode", "5");
- DispatchKeyValue(brake_r2, "model", "sprites/light_glow02.spr");
- DispatchKeyValueFloat(brake_r2, "scale", 0.2);
- DispatchSpawn(brake_r2);
- TeleportEntity(brake_r2, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(brake_r2, "SetParent", brake_r, brake_r, 0);
- SetVariantString("light_rr")
- AcceptEntityInput(brake_r2, "SetParentAttachment", brake_r, brake_r, 0);
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][3] = brake_r2;
- /* new headlight_l = CreateEntityByName("point_spotlight");
- DispatchKeyValue(headlight_l, "parentname", ent_name);
- DispatchKeyValue(headlight_l, "targetname", light_index);
- DispatchKeyValueVector(headlight_l, "rendercolor", white_rgb);
- DispatchKeyValue(headlight_l, "inner_cone", "10");
- DispatchKeyValue(headlight_l, "cone", "20");
- DispatchKeyValueFloat(headlight_l, "spotlight_radius", 40.0);
- DispatchKeyValueFloat(headlight_l, "distance", 400.0);
- DispatchKeyValue(headlight_l, "brightness", "1");
- DispatchKeyValue(headlight_l, "rendercolor", "255 255 255");
- DispatchKeyValue(headlight_l, "_light", "255 255 255 255");
- DispatchKeyValue(headlight_l, "style", "0");
- DispatchKeyValue(headlight_l, "pitch", "90");
- DispatchKeyValue(headlight_l, "renderamt", "200");
- DispatchSpawn(headlight_l);
- TeleportEntity(headlight_l, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(headlight_l, "SetParent", headlight_l, headlight_l, 0);
- SetVariantString("light_fl")
- AcceptEntityInput(headlight_l, "SetParentAttachment", headlight_l, headlight_l, 0);
- AcceptEntityInput(headlight_l, "LightOn");
- g_CarLights[car_index2][6] = headlight_l;
- new headlight_r = CreateEntityByName("point_spotlight");
- DispatchKeyValue(headlight_r, "parentname", ent_name);
- DispatchKeyValue(headlight_r, "targetname", light_index);
- DispatchKeyValueVector(headlight_r, "rendercolor", white_rgb);
- DispatchKeyValue(headlight_r, "inner_cone", "10");
- DispatchKeyValue(headlight_r, "cone", "20");
- DispatchKeyValueFloat(headlight_r, "spotlight_radius", 40.0);
- DispatchKeyValueFloat(headlight_r, "distance", 400.0);
- DispatchKeyValue(headlight_r, "brightness", "1");
- DispatchKeyValue(headlight_r, "rendercolor", "255 255 255");
- DispatchKeyValue(headlight_r, "_light", "255 255 255 255");
- DispatchKeyValue(headlight_r, "style", "0");
- DispatchKeyValue(headlight_r, "pitch", "90");
- DispatchKeyValue(headlight_r, "renderamt", "200");
- DispatchSpawn(headlight_r);
- TeleportEntity(headlight_r, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name);
- AcceptEntityInput(headlight_r, "SetParent", headlight_r, headlight_r, 0);
- SetVariantString("light_fr")
- AcceptEntityInput(headlight_r, "SetParentAttachment", headlight_r, headlight_r, 0);
- AcceptEntityInput(headlight_r, "LightOn");
- g_CarLights[car_index2][7] = headlight_r; */
- if (car_police_lights[i] == 1)
- {
- new blue_1 = CreateEntityByName("env_sprite");
- DispatchKeyValue(blue_1, "parentname", ent_name);
- DispatchKeyValue(blue_1, "targetname", light_index);
- DispatchKeyValueFloat(blue_1, "HDRColorScale", 1.0);
- DispatchKeyValue(blue_1, "renderamt", "255");
- DispatchKeyValueVector(blue_1, "rendercolor", blue_rgb);
- DispatchKeyValueVector(blue_1, "angles", brake_angles);
- DispatchKeyValue(blue_1, "spawnflags", "3");
- DispatchKeyValue(blue_1, "rendermode", "5");
- DispatchKeyValue(blue_1, "model", "sprites/light_glow02.spr");
- /* DispatchKeyValue(blue_1, "spotlightwidth", "40");
- DispatchKeyValue(blue_1, "spotlightlength", "10"); */
- DispatchSpawn(blue_1);
- TeleportEntity(blue_1, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name)
- AcceptEntityInput(blue_1, "SetParent", blue_1, blue_1, 0);
- SetVariantString("light_bar1")
- AcceptEntityInput(blue_1, "SetParentAttachment", blue_1, blue_1, 0);
- AcceptEntityInput(blue_1, "HideSprite");
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][4] = blue_1;
- new blue_2 = CreateEntityByName("env_sprite");
- DispatchKeyValue(blue_2, "parentname", ent_name);
- DispatchKeyValue(blue_2, "targetname", light_index);
- DispatchKeyValueFloat(blue_2, "HDRColorScale", 1.0);
- DispatchKeyValue(blue_2, "renderamt", "255");
- DispatchKeyValueVector(blue_2, "rendercolor", blue_rgb);
- DispatchKeyValueVector(blue_2, "angles", brake_angles);
- DispatchKeyValue(blue_2, "spawnflags", "3");
- DispatchKeyValue(blue_2, "rendermode", "5");
- DispatchKeyValue(blue_2, "model", "sprites/light_glow02.spr");
- /* DispatchKeyValue(blue_2, "spotlightwidth", "40");
- DispatchKeyValue(blue_2, "spotlightlength", "10"); */
- DispatchSpawn(blue_2);
- TeleportEntity(blue_2, SpawnOrigin, NULL_VECTOR, NULL_VECTOR);
- SetVariantString(Car_Name)
- AcceptEntityInput(blue_2, "SetParent", blue_2, blue_2, 0);
- SetVariantString("light_bar2")
- AcceptEntityInput(blue_2, "SetParentAttachment", blue_2, blue_2, 0);
- AcceptEntityInput(blue_2, "HideSprite");
- g_CarLightQuantity[car_index2] += 1;
- g_CarLights[car_index2][5] = blue_2;
- CarSiren[ent] = false;
- }
- }
- // That was the bit for car lights. Now for seats. :)
- cars_seats[ent] = 0;
- if (car_passengers[i] > 0)
- {
- for ( new ic = 1; ic < car_passengers[i] + 1; ic++ )
- {
- new seat = CreateEntityByName("prop_vehicle_driveable");
- if(IsValidEntity(seat))
- {
- cars_seat_entities[ent][ic] = seat;
- Cars_Driver_Prop[seat] = -1;
- new String:Seat_Name[64];
- Format(Seat_Name, sizeof(Seat_Name), "%i_chair", seat);
- DispatchKeyValue(seat, "vehiclescript", "scripts/vehicles/chair.txt");
- DispatchKeyValue(seat, "model", car_passenger_seat[i][ic]);
- DispatchKeyValueFloat (seat, "MaxPitch", 360.00);
- DispatchKeyValueFloat (seat, "MinPitch", -360.00);
- DispatchKeyValueFloat (seat, "MaxYaw", 90.00);
- DispatchKeyValue(seat, "targetname", Seat_Name);
- DispatchKeyValue(seat, "solid","6");
- DispatchKeyValue(seat, "actionScale","1");
- DispatchKeyValue(seat, "EnableGun","0");
- DispatchKeyValue(seat, "ignorenormals","0");
- DispatchKeyValue(seat, "fadescale","1");
- DispatchKeyValue(seat, "fademindist","-1");
- DispatchKeyValue(seat, "VehicleLocked","0");
- DispatchKeyValue(seat, "screenspacefade","0");
- DispatchKeyValue(seat, "spawnflags", "256" );
- DispatchKeyValue(seat, "skin", "0");
- DispatchKeyValue(seat, "setbodygroup", "511" );
- TeleportEntity(seat, SpawnOrigin, SpawnAngles, NULL_VECTOR);
- DispatchSpawn(seat);
- ActivateEntity(seat);
- SetEntProp(seat, Prop_Data, "m_nNextThinkTick", -1);
- SDKHook(seat, SDKHook_Think, OnThink);
- AcceptEntityInput(seat, "TurnOff");
- ViewEnt[seat] = -1;
- car_fuel[seat] = 10.0;
- mpg[seat] = 10;
- cars_type[seat] = 100;
- SetVariantString(Car_Name)
- AcceptEntityInput(seat, "SetParent", seat, seat, 0);
- SetVariantString(car_passenger_attachment[i][ic]);
- AcceptEntityInput(seat, "SetParentAttachment", seat, seat, 0);
- cars_seats[ent] += 1;
- is_chair[seat] = 1;
- chairs_car[seat] = ent;
- }
- }
- }
- }
- }
- // Put these in OnPluginStart()
- RegConsoleCmd("sm_seat", Car_Seat, " -- Switch seats in a car if applicable.");
- ReadCarFile();
- // You probably need most of these at the start of the plugin
- // Car Buy Menu Load Arrays
- new car_quantity = 0;
- new car_quantity_vip = 0;
- new car_quantity_disabled = 0;
- new car_vip[MAX_CARS];
- new String:car_name[MAX_CARS][32];
- new String:car_model[MAX_CARS][256];
- new String:car_script[MAX_CARS][256];
- new car_skins[MAX_CARS];
- new car_price[MAX_CARS];
- new car_mpg[MAX_CARS];
- new car_lights[MAX_CARS];
- new car_police_lights[MAX_CARS];
- new car_view_enabled[MAX_CARS];
- new car_siren_enabled[MAX_CARS];
- new car_driver_view[MAX_CARS];
- new Float:car_gas[MAX_CARS];
- new car_passengers[MAX_CARS];
- new String:car_passenger_seat[MAX_CARS][11][128];
- new String:car_passenger_attachment[MAX_CARS][11][32];
- // Temporary Car Menu Arrays
- new selected_car[MAXPLAYERS+1];
- new selected_car_stowed[MAXPLAYERS+1];
- new selected_car_skin[MAXPLAYERS+1];
- new selected_car_type[MAXPLAYERS+1];
- new selected_car_index[MAXPLAYERS+1];
- new Float:selected_car_fuel[MAXPLAYERS+1];
- new String:selected_car_name[MAXPLAYERS+1][32];
- new m_ArmorValue;
- new MoneyOffset;
- // Individual Car Arrays
- new cars_type[MAX_ENTITIES];
- new cars_index[MAX_ENTITIES];
- new drivers_car[MAXPLAYERS+1];
- new Car_Entity[MAXPLAYERS+1][10];
- new Car_Type[MAXPLAYERS+1][10];
- new Car_Skin[MAXPLAYERS+1][10];
- new Float:Car_Gas[MAXPLAYERS+1][10];
- new Cars_Driver_Prop[MAX_ENTITIES];
- new cars_seats[MAX_ENTITIES];
- new cars_seat_entities[MAX_ENTITIES][11];
- new is_chair[MAX_ENTITIES];
- new chairs_car[MAX_ENTITIES];
- new car_owner[MAX_ENTITIES];
- public ReadCarFile()
- {
- carbuykv = CreateKeyValues("Commands")
- new String:file[256]
- BuildPath(Path_SM, file, 255, "configs/cars.ini")
- FileToKeyValues(carbuykv, file)
- KvRewind(carbuykv);
- if (!KvGotoFirstSubKey(carbuykv))
- {
- PrintToServer("[RP DEBUG] There are no cars listed in cars.ini, or there is an error with the file.");
- return;
- }
- new t = 1;
- do
- {
- KvGetSectionName(carbuykv, car_name[t], sizeof(car_name[]));
- car_price[t] = KvGetNum(carbuykv, "Price", 2000);
- car_vip[t] = KvGetNum(carbuykv, "VIP", 0);
- car_skins[t] = KvGetNum(carbuykv, "val_1", 0);
- KvGetString(carbuykv, "model", car_model[t], 255, "FUCK_YOU");
- PrecacheModel(car_model[t]);
- KvGetString(carbuykv, "script", car_script[t], 255, "FUCK_YOU");
- car_mpg[t] = KvGetNum(carbuykv, "mpg", 20);
- car_gas[t] = KvGetFloat(carbuykv, "gas_tank", 16.00);
- car_lights[t] = KvGetNum(carbuykv, "lights", 0);
- car_police_lights[t] = KvGetNum(carbuykv, "police_lights", 0);
- car_view_enabled[t] = KvGetNum(carbuykv, "view", 0);
- car_siren_enabled[t] = KvGetNum(carbuykv, "siren", 0);
- car_driver_view[t] = KvGetNum(carbuykv, "driver", 0);
- car_passengers[t] = KvGetNum(carbuykv, "passengers", 0);
- if (car_passengers[t] > 0)
- {
- new String:buffer_m[32];
- new String:buffer_a[32];
- for ( new ic = 1; ic < car_passengers[t] + 1; ic++ )
- {
- Format(buffer_m, sizeof(buffer_m), "p%i_model", ic);
- KvGetString(carbuykv, buffer_m, car_passenger_seat[t][ic], sizeof(car_passenger_seat), "UNKNOWN");
- if (StrEqual(car_passenger_seat[t][ic], "UNKNOWN", false))
- {
- car_passengers[t] = 0;
- PrintToServer("[Car] Car %s has an error for passenger seat model %i.", car_name[t], ic);
- break;
- }
- Format(buffer_a, sizeof(buffer_a), "p%i_attachment", ic);
- KvGetString(carbuykv, buffer_a, car_passenger_attachment[t][ic], sizeof(car_passenger_attachment), "UNKNOWN");
- if (StrEqual(car_passenger_attachment[t][ic], "UNKNOWN", false))
- {
- car_passengers[t] = 0;
- PrintToServer("[Car] Car %s has an error for passenger seat attachment %i.", car_name[t], ic);
- break;
- }
- }
- PrintToServer("[Car] Car %s has %i seat(s).", car_name[t], car_passengers[t]);
- }
- if (car_vip[t] == 1)
- {
- car_quantity_vip += 1;
- }
- else if (car_vip[t] == -1)
- {
- car_quantity_disabled += 1;
- }
- car_quantity += 1;
- t += 1;
- } while (KvGotoNextKey(carbuykv));
- KvRewind(carbuykv);
- car_view_enabled[100] = 1;
- car_driver_view[100] = 1;
- PrintToServer("[Car] Cars Loaded");
- PrintToServer("[Car] %i Cars were detected.", car_quantity - car_quantity_vip - car_quantity_disabled);
- PrintToServer("[Car] %i VIP Cars were detected.", car_quantity_vip);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement