SA-MP Forums Archive
Next question about adding Vehicle plate to spawned car - 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: Next question about adding Vehicle plate to spawned car (/showthread.php?tid=279687)



Next question about adding Vehicle plate to spawned car - Dystans - 28.08.2011

Hello again and as usually I turn to the problem. So, I've in a map command named /V < Car Name > which looks like this:

pawn Код:
CMD:v(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    return SendClientMessage(playerid, -1, "You must exit from THIS vehicle to create next car!");

    int
        name[20],
        sCar,
        CarID,
        Float:V_X,
        Float:V_Y,
        Float:V_Z,
        Float:V_Ang,
        Int;

    if(sscanf(params, "s[20]", name))
    return SendClientMessage(playerid, Blue, "Wrong car name!");

    sCar = GetVehicleModelIDFromName(name);

    if(sCar < 400 || sCar > 611)
    return SendClientMessage(playerid, Blue, ""#CRED"Use: "#CORANGE"/V < Car Name >");

    if(sCar == 425 || sCar == 432 || sCar == 447 || sCar == 520 && !IsPlayerAdmin(playerid))
    return SendClientMessage(playerid, Blue, "You can't create this vehicle, because you're not an administrator!");

    int vehicleid;
    SetVehicleToRespawn(vehicleid);
    GetPlayerPos(playerid,V_X, V_Y, V_Z);
    GetPlayerFacingAngle(playerid, V_Ang);
    Int = GetPlayerInterior(playerid);
    CarID = SetPVarInt(playerid, "VehicleSpawn", SetVehicleNumberPlate(CreateVehicle(sCar, V_X, V_Y, V_Z, V_Ang, -1, -1, -1), "Name of server"));
    SetVehicleVirtualWorld(CarID, GetPlayerVirtualWorld(playerid));

    PutPlayerInVehicle(playerid, CarID, 0);
    LinkVehicleToInterior(CarID, Int);
    int u_Message[128];

    format(u_Message, sizeof(u_Message), ""#CORANGE"You create: "#CBLUE"%s", VehicleNames[sCar - 400]);
    SendClientMessage(playerid, -1, u_Message);

    return 1;
}
function GetVehicleModelIDFromName:
pawn Код:
stock GetVehicleModelIDFromName(vname[])
{
    for(int i = 0; i < 211; i++)
    {
        if(strfind(VehicleNames[i], vname, true) != -1)
        return i + 400;
    }
    return -1;
}
When I'm trying to create car with license plate named "Name of server", then this command teleport me at front of docks in Las Venturas... Where is problem with this command? Thank in advance for help.


Re: Next question about adding Vehicle plate to spawned car - [MWR]Blood - 28.08.2011

pawn Код:
CMD:v(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid))
    return SendClientMessage(playerid, -1, "You must exit from THIS vehicle to create next car!");

    int
        name[20],
        sCar,
        CarID,
        Float:V_X,
        Float:V_Y,
        Float:V_Z,
        Float:V_Ang,
        Int;

    if(sscanf(params, "s[20]", name))
    return SendClientMessage(playerid, Blue, "Wrong car name!");

    sCar = GetVehicleModelIDFromName(name);

    if(sCar < 400 || sCar > 611)
    return SendClientMessage(playerid, Blue, ""#CRED"Use: "#CORANGE"/V < Car Name >");

    if(sCar == 425 || sCar == 432 || sCar == 447 || sCar == 520 && !IsPlayerAdmin(playerid))
    return SendClientMessage(playerid, Blue, "You can't create this vehicle, because you're not an administrator!");

    int vehicleid;
    SetVehicleToRespawn(vehicleid);
    GetPlayerPos(playerid,V_X, V_Y, V_Z);
    GetPlayerFacingAngle(playerid, V_Ang);
    Int = GetPlayerInterior(playerid);
    CarID = CreateVehicle(sCar, V_X, V_Y, V_Z, V_Ang, -1, -1, -1);
    SetPVarInt(playerid, "VehicleSpawn", 1);// or whatever you want to do with the pvar here
    SetVehicleNumberPlate(CarID,"Name of server");
    PutPlayerInVehicle(playerid, CarID, 0);
    LinkVehicleToInterior(CarID, Int);
    int u_Message[128];

    format(u_Message, sizeof(u_Message), ""#CORANGE"You create: "#CBLUE"%s", VehicleNames[sCar - 400]);
    SendClientMessage(playerid, -1, u_Message);

    return 1;
}
Try this, it should work!


Re: Next question about adding Vehicle plate to spawned car - Dystans - 28.08.2011

Delux13, thanks, now it's working very good. Thread may be closed.