Old car issue
#1

Hey.. sometimes when I use /oldcar I the number I get is 0..
Any reason why?

pawn Код:
if(strcmp(cmd, "/oldcar", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            format(string, sizeof(string), "Your old car was: %d",gLastCar[playerid]);
            SendClientMessage(playerid, COLOR_GREY, string);
        }
        return 1;
    }
Reply
#2

Where do you get the information about your previous car?
OnPlayerEnterVehicle?
Reply
#3

What do you mean?
Reply
#4

EPIC. : D

Where do you set the "lastcar" variable at?
Reply
#5

In what public do you store gLastCar[playerid] with the ID of the car?

example:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER) {gLastCar[playerid] == GetPlayerVehicleID(playerid);}
    return 1;
}
Reply
#6

They won't have entered a vehicle since they connected.
They need to have entered a car for gLastCar[playerid] to have a vehicle ID in it.
Reply
#7

A good tip would be to do like this;
pawn Код:
new gLastCar[MAX_PLAYERS] = -1;

if(strcmp(cmd, "/oldcar", true) == 0)
{
    if(gLastCar[playerid] == -1) return SendClientMessage(playerid, COLOR_RED, "Error: You have not entered a car since you logged in.");

    format(string, sizeof(string), "Your old car was: %d",gLastCar[playerid]);
    SendClientMessage(playerid, COLOR_GREY, string);

    return 1;
}
And then include what I wrote in the previous post;

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER) {gLastCar[playerid] == GetPlayerVehicleID(playerid);}
    return 1;
}
Reply
#8

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        new oldcar = gLastCar[playerid];
That's what I found.. its part of it.. so dont expect for return or close it
Reply
#9

Still not fixed.. cant figure out why.. still saying the old car is 0... and so wierd cuz it worked and i didnt do anything to change it..

more ideas?
Reply
#10

How do you set it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)