How to get this info?
#1

Hi, im beginner @ pawn scripting and i need some help with this.
I want show a message when someone get in a vehicle,
the info to show is:
Vehicle ID, Vehicle name, what category of vehicle is it, where can be modified and the cost of the vehicle.

I saw some scripts and i think this could be a way to make it possible.
pawn Код:
enum CarInfo{
    CarName[24],
    CarType[24],
    CarMod[24],
    CarCost
};
new Cars[][CarInfo] = {
    ("Landstalker", "Off Road", "Transfender", 8500),
    ("Bravura", "Saloons", "Transfender", 15000),
    ("Buffalo", "Sport Vehicles", "Transfender", 35000),
    ...
};
The question is, How to get that info in "SendClientMessage" function? or is there another way to make it?
and tell me if i made a mistake.

thanks in advance.
Reply
#2

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
new string[128];
format(string, sizeof(string), "%s, %s, %s, %d", Cars[modelid-400][CarName], Cars[modelid-400][CarType], Cars[modelid-400][CarMod], Cars[modelid-400][CarCost]);
SendClientMessage(playerid, 0xFFFFFFFF, string);
Reply
#3

i just tried that and when i get into the vehicle, it shows me:
Код:
** Model: (Alpha) Category: (nsfender) Mod: () Cost: ($0) // in Alpha
** Model: (Buffalo) Category: (ransfender) Mod: () Cost: ($0) // in Buffalo
** Model: (Savanna) Category: (ow Co) Mod: () Cost: ($0) // in Savanna
this is the code i used:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new modelid = GetVehicleModel(vehicleid);
        new string[128];
        format(string, sizeof(string), "** Model: (%s) Category: (%s) Mod: (%s) Cost: ($%d)", Cars[modelid-400][CarName], Cars[modelid-400][CarType], Cars[modelid-400][CarMod], Cars[modelid-400][CarCost]);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
    }
}
Reply
#4

EDIT: Sorry, misread.

EDIT 2: Try this:

pawn Код:
new Cars[3][CarInfo] = {
    {"Landstalker", "Off Road", "Transfender", 8500},
    {"Bravura", "Saloons", "Transfender", 15000},
    {"Buffalo", "Sport Vehicles", "Transfender", 35000},
    ...
};
(3 Is the amount of variables to create)
Reply
#5

Replace ( ) with { }

pawn Код:
new Cars[][CarInfo] = {
    {"Landstalker", "Off Road", "Transfender", 8500},
    {"Bravura", "Saloons", "Transfender", 15000},
    {"Buffalo", "Sport Vehicles", "Transfender", 35000},
    ...
};
Reply
#6

Cool,

i added the number of vehicles:
pawn Код:
new Cars[212][CarInfo] = {
and changed ( ) for { } and it works.
thanks alot for your help guys

thread closed
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)