[Suggestion] Vehicle number plate
#1

A very important function for SetVehicleNumberPlate(..); would be GetVehicleNumberPlate(vehicleid); which should return the number plate string.

It's veryveryveryvery important to also give a use to the number plate system.

pawn Код:
new str[32];
str = GetVehicleNumberPlate(vehicleid);
SendClientMessage(playerid,COLOR_WHITE,str);
Reply
#2

Just save the number to a string array every time you set it.
Reply
#3

pawn Код:
new NumberPlate[MAX_VEHICLES][40]; // At top of script
pawn Код:
stock SetVehicleNumberPlateEx(vehicleid,numberplate[])
{
    if(vehicleid != INVALID_VEHICLE_ID)
    {
        SetVehicleNumberPlate(vehicleid,numberplate[])
        NumberPlate[vehicleid] = numberplate;
    }
    else return 0;
    return 1;
}
pawn Код:
stock GetVehicleNumberPlate(vehicleid)
{
    if(vehicleid != INVALID_VEHICLE_ID)
    {
        return NumberPlate[vehicleid];
    }
    else return 0;
}
Try this. Untested but supposed to work. It will just return 0 if the numberplate hasn't been set.

I know I can type it shorter but this is my way to ident.
Reply
#4

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Just save the number to a string array every time you set it.
Why? Memory usage?

I don't think it's hard to make a function like that.
Reply
#5

Indeed, it isn't but you wanted something like this? Otherwise it is nice for players who arent pro.
Reply
#6

I'm making this, not tested.

If not work, please post.

Here's a include:
pawn Код:
new LicPlate[MAX_VEHICLES][32];
   
#define SetVehicleNumberPlate A_SetVehicleNumberPlate

stock A_SetVehicleNumberPlate(vehicleid, numberplate[])
{
    format(LicPlate[vehicleid], 32, "%s", numberplate);
    return SetVehicleNumberPlate(vehicleid, numberplate);
}

stock GetVehicleNumberPlate(vehicleid, numberplate[], len)
{
    if(vehicleid == INVALID_VEHICLE_ID) return 0;
    format(numberplate, len, "%s", LicPlate[vehicleid]);
    return numberplate;
}
Put this in your OnGameModeInit()

pawn Код:
for(new i; i < MAX_VEHICLES; i++)
    {
        LicPlate[i] = "XYZR 000";
    }
Reply
#7

Quote:
Originally Posted by kurta999
Посмотреть сообщение
pawn Код:
new LicPlate[MAX_VEHICLES][32];
   
#define SetVehicleNumberPlate A_SetVehicleNumberPlate
Shouldn't you make undef the old one first? And this needs to be at the end of scripyt :P
Reply
#8

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Indeed, it isn't but you wanted something like this? Otherwise it is nice for players who arent pro.
Well it would be easier and better if there is a native function.
Reply
#9

Indeed, I agree, but it's only optional.
Reply
#10

Try.:
pawn Код:
// Created by me  
// thanks ****** For the method to not replace the function names
new
    LicPlate[MAX_VEHICLES][32+1];
   
native
    P_SetVehicleNumberPlate(vehicleid, numberplate[]) = SetVehicleNumberPlate;

#define SetVehicleNumberPlate \
                SetVehicleNumberPlateEx
   
stock
    SetVehicleNumberPlateEx(vehicleid, numberplate[])
{
    format(LicPlate[vehicleid], 32+1, "%s", numberplate);
    return P_SetVehicleNumberPlate(vehicleid, LicPlate[vehicleid]); // or numberplate
}

#define GetVehicleNumberPlate(%0) \
                LicPlate[%0]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)