SA-MP Forums Archive
How to get this info? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to get this info? (/showthread.php?tid=178553)



How to get this info? - Rulaz - 22.09.2010

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.


Re: How to get this info? - MadeMan - 22.09.2010

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);



Respuesta: How to get this info? - Rulaz - 22.09.2010

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);
    }
}



Re: How to get this info? - [XST]O_x - 22.09.2010

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)


Re: How to get this info? - MadeMan - 22.09.2010

Replace ( ) with { }

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



Respuesta: How to get this info? - Rulaz - 22.09.2010

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