[Suggestion] Vehicle number plate -
scottyishere - 29.11.2010
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);
Re: [Suggestion] Vehicle number plate -
Mauzen - 29.11.2010
Just save the number to a string array every time you set it.
Re: [Suggestion] Vehicle number plate -
Jochemd - 29.11.2010
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.
Re: [Suggestion] Vehicle number plate -
scottyishere - 29.11.2010
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.
Re: [Suggestion] Vehicle number plate -
Jochemd - 29.11.2010
Indeed, it isn't but you wanted something like this? Otherwise it is nice for players who arent pro.
Re: [Suggestion] Vehicle number plate -
kurta999 - 29.11.2010
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";
}
Re: [Suggestion] Vehicle number plate -
Jochemd - 29.11.2010
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
Re: [Suggestion] Vehicle number plate -
scottyishere - 29.11.2010
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.
Re: [Suggestion] Vehicle number plate -
Jochemd - 29.11.2010
Indeed, I agree, but it's only optional.
Re: [Suggestion] Vehicle number plate -
smeti - 29.11.2010
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]