Yeap, it is better to use PVARS
(In most of the Examples is useless.) But for me, get a more beautiful code ![]() Lorenc: Your code will not work with variations of hacking (Example: 9999999.999 to 99999.99999 ![]() |
PVars are both slower and larger in memory footprint. There are VERY few reasons for using them over well-designed code.
|
You can use || ('or' operator) but this cleo has massive integers installed.. Anyway, your one wouldn't work with different variations as well. 0xDBB9F = 899999 0xF423F = 999999 (Which is what I have, except with some decimal numbers) Hexidecimal is neat. Anyway, about PVars, I don't use one PVar inside my gamemode, and don't want to lol. Char arrays, and other techniques keep me away from it. |
Seems PVars are just for convenience really, all the advantages (apart from that one about holding large strings) are purely to make things easier (Auto delete, no need for IsPlayerConnected, cross-script use etc)
Also, like ****** said about compile time checking, what if you misspell a PVar? Since they are strings not labels an error like this would be annoying! Anyway, I really should get this back on topic by posting a useful snippet... Can't think of any that I haven't posted already though ![]() |
Hey, is it possible to make sunch function like "IsCarFalling"? Because I dont think checking Z coordinate is the best way, as there are some roads in high, also mt chilliad.
|
pawn Код:
Код:
GameTextForPlayerEx(playerid,"Firecat still lives in 2007",3500,3,playerid); |
pawn Код:
Код:
GameTextForPlayerEx(playerid,"Firecat still lives in 2007",3500,3,playerid); |
Velocity is the only possible way afaik (vehicle velocity of the Z axis).
|
Can you give me an example? Because I suck at maths, especially such formulas
|
But why would you use this GameTextForPlayerEx if you're not using the format parameters? However, as mentioned before, why using those global variables? I always use these (these were all tested
![]() pawn Код:
WARNING: You cannot use these function things in a return statement thing. Example, this will not work: pawn Код:
pawn Код:
|
GameTextForPlayerEx(playerid, string[], time, style, {Float,_}:...);
GameTextForAllEx(string[], time, style, {Float,_}:...);
SendMessage(playerid, color, message[], {Float,_}:...);
SendMessageToAll(color, message[], {Float,_}:...);
#if !defined FMsg
stock FMsg[400];
#endif
stock GameTextForPlayerEx(playerid,const string[],time,style)return GameTextForPlayer(playerid,string,time,style);
#define GameTextForPlayerEx(%0,%1,%2,%3,%4) format(FMsg, sizeof(FMsg),%1,%4), GameTextForPlayer(%0,FMsg,%2,%3)
stock GameTextForAllEx(const string[],time,style)return GameTextForAll(string,time,style);
#define GameTextForAllEx(%0,%1,%2,%3) format(FMsg, sizeof(FMsg),%0,%3), GameTextForAll(FMsg,%1,%2)
#define SendMessage(%0,%1,%2) format(FMsg, sizeof(FMsg), %2), SendClientMessage(%0,%1,FMsg)
#define SendMessageToAll(%0,%1) format(FMsg, sizeof(FMsg), %1), SendClientMessageToAll(%0,FMsg)
stock IsWaterVehicle(model)
{
switch(model)
{
case 472:{ return 1;}
case 473:{ return 1;}
case 493:{ return 1;}
case 595:{ return 1;}
case 484:{ return 1;}
case 430:{ return 1;}
case 453:{ return 1;}
case 452:{ return 1;}
case 446:{ return 1;}
case 454:{ return 1;}
case 460:{ return 1;}
default: return 0;
}
return 0;
}
stock IsAirVehicle(model)
{
switch(model)
{
case 592:{ return 1;}
case 577:{ return 1;}
case 511:{ return 1;}
case 512:{ return 1;}
case 593:{ return 1;}
case 520:{ return 1;}
case 553:{ return 1;}
case 476:{ return 1;}
case 519:{ return 1;}
case 513:{ return 1;}
case 548:{ return 1;}
case 425:{ return 1;}
case 417:{ return 1;}
case 487:{ return 1;}
case 497:{ return 1;}
case 488:{ return 1;}
case 563:{ return 1;}
case 447:{ return 1;}
case 469:{ return 1;}
default: return 0;
}
return 0;
}
This stock functions will check if if vehicle is a boat or an airplane/helicopter
-code- |
stock IsBoatVehicle( model )
{
static const
BoatVehicles[ ] = {
472, 473, 595, 493, 430, 453, 484, 446, 452, 454
}
;
for( new i; i < sizeof( BoatVehicles ); i++ ) {
if( BoatVehicles[ i ] == model ) return 1;
}
return 0;
}
stock IsAirVehicle( model )
{
static const
AirVehicles[ ] = {
577, 511, 592, 520, 593, 512, 476, 553, 460, 519, 548, 425, 488, 487, 417, 563, 497, 447, 469
}
;
for( new i; i < sizeof( AirVehicles ); i++ ) {
if( AirVehicles[ i ] == model ) return 1;
}
return 0;
}
stock IsPlayerFemale(Model) {
if(Model < 0 || Model > 299) {
return false;
}
static const Female[] = {
9, 10, 11, 12, 13, 31, 38, 39, 40, 41, 53, 54, 55, 56, 63, 64, 65, 69, 75, 76, 77, 85, 87, 88, 89, 90, 91, 92, 93, 129, 130, 131, 138, 139, 140, 141, 145, 148, 150, 151, 152, 157, 169, 172,
178, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 201, 205, 207, 211, 214, 215, 216, 218, 219, 224, 225, 226, 231, 232, 233, 237, 238, 243, 244, 245, 246, 251, 256, 257, 263, 298
};
for(new FemaleID = 0; FemaleID < sizeof(Female); FemaleID++) {
if(Female[FemaleID] == Model) {
return true;
}
}
return false;
}
stock IsPlayerSkin(Model) {
if(IsPlayerMale(Model) || IsPlayerFeamle(Model)) {
return true;
}
return false;
}
Could you post an example of a bit array?
I'm not really sure what the term means, I thought it meant a single 32 bit variable used for 32 boolean values. Are they those "IsThisASomething" functions where you have an array of hex numbers then an if statement with some bitwise shifting and stuff... It's hard to explain, I've seen some posted before, I never understood them and I don't really know what keywords to use to search (apart from "bit array" but I didn't really find anything) I may as well ask while it's on topic! |
Could you post an example of a bit array?
I'm not really sure what the term means, I thought it meant a single 32 bit variable used for 32 boolean values. Are they those "IsThisASomething" functions where you have an array of hex numbers then an if statement with some bitwise shifting and stuff... It's hard to explain, I've seen some posted before, I never understood them and I don't really know what keywords to use to search (apart from "bit array" but I didn't really find anything) I may as well ask while it's on topic! |
enum type
{
TYPE_UNKNOWN,
TYPE_LAND,
TYPE_WATER,
// ...
}
new vehicleTypes[212 char] = { 16777216 /* 1 << 24 */, ... };