Raised This Month: $ Target: $400
 0% 

I need working vehicle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Swolly
Senior Member
Join Date: Jul 2018
Location: Turkey
Old 01-23-2019 , 05:06   I need working vehicle
Reply With Quote #1

I want make my server for vehicle but my script not working who my for fix

Code:
#include <sourcemod>
#include <sdktools>    

#define     EF_NODRAW 32
#define        COLLISION_GROUP_PLAYER 5
#define     HIDEHUD_WEAPONSELECTION 1
#define     HIDEHUD_CROSSHAIR 256
#define     HIDEHUD_INVEHICLE 1024

public OnPluginStart()
{    
    RegAdminCmd("sm_car", Command_CAR, ADMFLAG_ROOT);
    RegAdminCmd("sm_car2", Command_CAR2, ADMFLAG_ROOT);
}

public OnMapStart()
{
    PrecacheModel("models/natalya/vehicles/natalyas_mustang_2.mdl");
}

public Action:Command_CAR(client, args)
{
    new String:name[255];
    GetClientName(client, name, sizeof(name));

    decl Ent;   
    Ent = CreateEntityByName("prop_vehicle_driveable"); 

    DispatchKeyValue(Ent, "vehiclescript", "scripts/vehicles/natalyas_mustang.txt");
    DispatchKeyValue(Ent, "model", "models/natalya/vehicles/natalyas_mustang_2.mdl");
    DispatchKeyValueFloat (Ent, "MaxPitch", 360.00);
    DispatchKeyValueFloat (Ent, "MinPitch", -360.00);
    DispatchKeyValueFloat (Ent, "MaxYaw", 90.00);
    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, "setbodygroup", "511" );
    SetEntProp(Ent, Prop_Send, "m_nSolidType", 2);
    DispatchSpawn(Ent);
    ActivateEntity(Ent);

    decl Float:FurnitureOrigin[3];
    decl Float:ClientOrigin[3];
    decl Float:EyeAngles[3];
    GetClientEyeAngles(client, EyeAngles);
    GetClientAbsOrigin(client, ClientOrigin);

    FurnitureOrigin[0] = (ClientOrigin[0] + (50 * Cosine(DegToRad(EyeAngles[1]))));
    FurnitureOrigin[1] = (ClientOrigin[1] + (50 * Sine(DegToRad(EyeAngles[1]))));
    FurnitureOrigin[2] = (ClientOrigin[2]);


    TeleportEntity(Ent, FurnitureOrigin, NULL_VECTOR, NULL_VECTOR);

    SetEntProp(Ent, Prop_Data, "m_nNextThinkTick", -1);
	SDKHook(ent, SDKHook_Think, OnThink);		
		
    SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", 0);
    SetEntProp(client, Prop_Send, "m_iObserverMode", 1); 

    // force players in.
    if (client != 0)
    {
        AcceptEntityInput(Ent, "use", client);
    }
}  

public Action:Command_CAR2(client, args)
{
    LeaveVehicle(client);
}  

LeaveVehicle(client)
{
    new vehicle = GetEntPropEnt(client, Prop_Send, "m_hVehicle");
    if (IsValidEntity(vehicle))
    {
        AcceptEntityInput(client, "SetParent");
        SetVariantString("vehicle_driver_exit");
        AcceptEntityInput(client, "SetParentAttachment");        

        new Float:ExitAng[3];
        GetEntPropVector(vehicle, Prop_Data, "m_angRotation", ExitAng);
        ExitAng[0] = 0.0;
        ExitAng[1] += 90.0;
        ExitAng[2] = 0.0;
        
    
        AcceptEntityInput(client, "ClearParent");    
        
        SetEntPropEnt(client, Prop_Send, "m_hVehicle", -1);
    
        SetEntPropEnt(vehicle, Prop_Send, "m_hPlayer", -1);
    
        SetEntityMoveType(client, MOVETYPE_WALK);
    
        SetEntProp(client, Prop_Send, "m_CollisionGroup", COLLISION_GROUP_PLAYER);        
        
        new hud = GetEntProp(client, Prop_Send, "m_iHideHUD");
        hud &= ~HIDEHUD_WEAPONSELECTION;
        hud &= ~HIDEHUD_CROSSHAIR;
        hud &= ~HIDEHUD_INVEHICLE;
        SetEntProp(client, Prop_Send, "m_iHideHUD", hud);
        
        new EntEffects = GetEntProp(client, Prop_Send, "m_fEffects");
        EntEffects &= ~EF_NODRAW;
        SetEntProp(client, Prop_Send, "m_fEffects", EntEffects);

        SetEntProp(vehicle, Prop_Send, "m_nSpeed", 0);
        SetEntPropFloat(vehicle, Prop_Send, "m_flThrottle", 0.0);
        AcceptEntityInput(vehicle, "TurnOff");

        SetEntPropFloat(vehicle, Prop_Data, "m_flTurnOffKeepUpright", 0.0);
    
        SetEntProp(vehicle, Prop_Send, "m_iTeamNum", 0);
        
        TeleportEntity(client, NULL_VECTOR, ExitAng, NULL_VECTOR);
        SetClientViewEntity(client, client);
    }

    new index = -1;
    while ((index = FindEntityByClassname(index, "prop_vehicle_driveable")) != -1)
        RemoveEdict(index);

    new plyr_gun2 = GetPlayerWeaponSlot(client, 2);
    if (IsValidEntity(plyr_gun2))
    {
        RemovePlayerItem(client, plyr_gun2);
        RemoveEdict(plyr_gun2);
        GivePlayerItem(client, "weapon_knife", 0);
    }    
    SetClientViewEntity(client, client);
}
Swolly is offline
Indarello
Senior Member
Join Date: Nov 2015
Location: Russia
Old 01-23-2019 , 05:12   Re: I need working vehicle
Reply With Quote #2

Wait, maybe valve will patch it
Indarello is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode