SA-MP Forums Archive
Vehicle help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle help. (/showthread.php?tid=658954)



Vehicle help. - DarknesS1988 - 17.09.2018

I have definied:
PHP код:
#define VEHICLE_TYPE_LAW_ENFOREMENT 1
#define VEHICLE_TYPE_CIVILIAN 2
#define VEHICLE_TYPE_DRIVER 3
#define VEHICLE_TYPE_ADMIN 4 
Is it somehow possible change this
PHP код:
CreateVehicle(modelid, X,Y,Z + 2.0,A + 90.0,0,0, 604800); 
with this:
PHP код:
CreateStaticVehicle(ctype,modelid,Float:X,Float:Y,Float:Z,Float:A,ColorOne,ColorTwo);//(or 1,2,3,4) 
In This command
PHP код:
dcmd_v(playerid, params[])
{
    if(
IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] > 0)
    {
        new 
idx,modelid;
        new 
tmp[256],string[256];
        
tmp = strtok(params, idx);
        if(!
strlen(tmp))
        {
            
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /v (Modelid/Name)");
            return 
1;
        }
        
        
        if(
isNumeric(tmp))
        {
        
modelid = strval(tmp);
        
        }else{
        
modelid = GetVehicleModelIDFromName( tmp );
        if( 
modelid == -1 )
        {
        
SendClientMessage(playerid, COLOR_ERROR, "[ERROR] Invalid MODELID/NAME");
        return 
1;
        }
        }
        if(
modelid < 400 || modelid > 611)
        {
        
SendClientMessage(playerid, COLOR_ERROR, "Enter A Vehicle Modelid Between 400 And 611");
        return 
1;
        }
        new 
Float:X, Float:Y, Float:Z, Float:A;//,Interior,World;
        
GetPlayerPos(playerid, X, Y, Z);
        
GetPlayerFacingAngle(playerid, A);
        
//Interior = GetPlayerInterior(playerid);
        //World = GetPlayerVirtualWorld(playerid);
        
GetXYInFrontOfPlayer(playerid, X, Y, 5.0);
        
CreateVehicle(modelid, X,Y,Z + 2.0,A + 90.0,0,0, 604800);
        
format(string, sizeof(string), "%s Spawned A (%s), Modelid: (%d)", PlayerInfo[playerid][pName], aVehicleNames[modelid - 400], modelid);
}else{
    
SendClientMessage(playerid, COLOR_ERROR, "Unknown Command! Type /cmds For Available Commands.");
    }
    return 
1;
} 
OnVehicleSpawn
PHP код:
public OnVehicleSpawn(vehicleid)
{
    new 
string[256];
    if (
CarInfo[vehicleid][cOwned] > 0)
    {
    new 
playerid = CarInfo[vehicleid][cOwned];
    
PlayerInfo[playerid][pCar] = 0;
    }
    
format(string, sizeof(string), "Not Owned");
    
strmid(CarInfo[vehicleid][cOwner], string, 0, strlen(string), 256);
    
CarInfo[vehicleid][cOwned] = -1;
    
CarInfo[vehicleid][cLock] = 0;
    
CarInfo[vehicleid][cSold] = 0;
    
CarInfo[vehicleid][cValue] = 0;
    
SetVehicleHealth(vehicleid,999);
    return 
1;
} 
Enum from my script maybe can be used:
PHP код:
enum cInfo
{
    
cType,
    
cModel,
    
Float:cLocationX,
    
Float:cLocationY,
    
Float:cLocationZ,
    
Float:cLocationA,
    
cLocationI,
    
cLocationW,
    
cColorOne,
    
cColorTwo,
    
cOwner[MAX_PLAYER_NAME],
    
cOwned,
    
cLock,
    
cValue,
    
cSellable,
    
cSold,
    
cSpawnTime
}; 



Re: Vehicle help. - DarknesS1988 - 19.09.2018

Anyone please? And btw, what is happening with forums? Database error yesterday (the whole freaking day)