SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/05/2019, 10:26 PM   #11
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 639
Reputation: 42
Default Re: This function is trolling me.

Ok let's make it clear.

v_Model saves the vehicle model (from 400 to 611).

and vid refers to vehicle DATABSE id (created or loaded), so what should i do? Attach label to vehicle db id?
__________________



Find what you love and let it kill you.
Symon is offline   Reply With Quote
Old 21/05/2019, 10:36 PM   #12
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 22
Default Re: This function is trolling me.

Uhm... not if it's not the same.
How is the vehicle created? I guess you have CreateVehicle somewhere which returns the vehicleid.
So to store and use it later, you do someArray[id] = CreateVehicle(...)
You could use the array you have already, so you don't even have to change that much.
Code:
VehicleData[vid][v_ID] = CreateVehicle(...);//AddStaticVehicle(Ex) also works
Plastikmensch is offline   Reply With Quote
Old 21/05/2019, 10:57 PM   #13
austin070
Huge Clucker
 
austin070's Avatar
 
Join Date: Aug 2010
Posts: 372
Reputation: 18
Default Re: This function is trolling me.

Quote:
Originally Posted by KeyOfKey View Post
Ok let's make it clear.

v_Model saves the vehicle model (from 400 to 611).

and vid refers to vehicle DATABSE id (created or loaded), so what should i do? Attach label to vehicle db id?
When the vehicle spawns, the server assigns it the next vehicleid available. The first car spawned in the script is vehicleid 0. If you type /dl in-game, you can see the server-assigned vehicleid of a certain vehicle. As far as your script goes, if you assign a specific vehicle to a global variable when it is created, you can always access that specific vehicle through the variable.

Plastikmensch's code snippet is a good example.

Quote:
Originally Posted by Plastikmensch View Post
Uhm... not if it's not the same.
How is the vehicle created? I guess you have CreateVehicle somewhere which returns the vehicleid.
So to store and use it later, you do someArray[id] = CreateVehicle(...)
You could use the array you have already, so you don't even have to change that much.
Code:
VehicleData[vid][v_ID] = CreateVehicle(...);//AddStaticVehicle(Ex) also works

P.S. I corrected my misuse of pronouns. Sorry.
austin070 is offline   Reply With Quote
Old 21/05/2019, 11:14 PM   #14
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 639
Reputation: 42
Default Re: This function is trolling me.

I have v_Create (temp variable) to create the vehicle with the command. Here is the full cmd:

pawn Code:
CMD:cvehicle(playerid, params[])
{
    if(Player[playerid][AdminLevel] < 5) return ErrorMessage(playerid, COLOR_ERROR, 1);

    new car[50], price, vehid, color1, color2, Float:x, Float:y, Float:z, Float:angle, string[300], id;
   
    id = Iter_Free(ServerVehicles);

    if(sscanf(params, "s[50]ddd", car, price, color1, color2)) return SendUsageMessage(playerid, "/cvehicle [vehicle id/name] [price] [color 1 (255 for random)] [color 2 (255 for random)]");

    if(!isnumeric(car))
    {
        vehid = GetVehicleModelIDFromName(car);
    }
    else
    {
        vehid = strval(car);
    }

    if(color1==255) color1=random(256);
    if(color2==255) color2=random(256);
       
    if((vehid < 400 || vehid > 611)) return SendErrorMessage(playerid, "Invalid vehicle ID.");
    if((color1 < 0 || color1 > 255) || color2 < 0 || color2 > 255) return SendErrorMessage(playerid, "Vehicle color must be between -1 and 255.");
    if((price < 1) || (price > 999999)) return SendErrorMessage(playerid, "Invalid price.");
   
    if(!Iter_Contains(ServerVehicles, id))
    {
        Iter_Add(ServerVehicles, id);
       
        VehicleData[id][v_DBID] = id;
       
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, angle);

        format(VehicleData[id][v_Owner], MAX_PLAYER_NAME, "-");

        VehicleData[id][v_Model] = vehid;

        VehicleData[id][v_Color1] = color1;
        VehicleData[id][v_Color2] = color2;

        SetVehicleNumberPlate(VehicleData[id][v_Create], VehicleData[id][v_Plate]);

        VehicleData[id][v_Price] = price;

        VehicleData[id][v_PosX] = x;
        VehicleData[id][v_PosY] = y;
        VehicleData[id][v_PosZ] = z;
        VehicleData[id][v_PosA] = angle;

        LoadVehicleMod(vehid, id);

        format(string, sizeof(string), "INSERT INTO `vehicles` (`id`, `owner`, `model`, `color1`, `color2`, `price`, `v_PosX`, `v_PosY`, `v_PosZ`, `v_PosA`) VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%f', '%f', '%f', '%f')", id, VehicleData[id][v_Owner], vehid, color1, color2, price, x, y, z, angle);
        mysql_tquery(g_SQL, string);

        VehicleData[id][v_Create] = CreateVehicle(vehid, x, y, z, angle, color1, color2, -1);

        UpdateVehicleLabel(id);

        SCMEX(playerid, 0xFFFF00FF, "You have created a(n) %s. ID: %d - Price: %s - Color 1: %d - Color 2: %d", VehicleNames[vehid-400], id, formatInt(price), color1, color2);
    }
    return 1;
}
__________________



Find what you love and let it kill you.
Symon is offline   Reply With Quote
Old 22/05/2019, 12:00 AM   #15
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 639
Reputation: 42
Default Re: This function is trolling me.

You can close. I fixed, but there's another which im gonna create a new topic about.
__________________



Find what you love and let it kill you.
Symon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Map] TROLLING MAP Wreeper Maps 2 06/09/2018 09:46 AM
Trolling at its best freddy smyth Everything and Nothing 17 01/03/2013 06:25 PM
[FilterScript] Trolling FS Majed Filterscripts 34 12/10/2012 02:09 AM
Pawno trolling me CutX Scripting Help 12 01/09/2012 11:36 AM
Fl Studio 10 - Trolling :D KeeDee Everything and Nothing 0 06/03/2012 11:53 PM


All times are GMT. The time now is 11:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.