Vehicle without engine issue
#1

Im trying to make the vehicles to automatically be drivable if they have no engine, for example bmx.If you enter a vehicle without engine, you should be able to drive it without typing /engine.

EnginedVehicles enum:
Код:
new EnginedVehicles[] =
{
	400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410,
	411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421,
	422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432,
	433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443,
	444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454,
	455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465,
	466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476,
	477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488,
	489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499,
	500, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513,
	514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
	525, 526, 527, 527, 529, 530, 531, 532, 533, 534, 535,
	536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546,
	547, 548, 549, 550, 551, 552, 553, 554, 556, 557, 558,
	559, 560, 561, 562, 563, 565, 566, 567, 568, 571, 572,
	573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583,
	585, 586, 587, 588, 589, 592, 593, 595, 596, 597, 598,
	599, 600, 601, 602, 603, 604, 605, 609
};
OnPlayerStateChange:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) //When player enters the vehicle.
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
	    if(!EnginedVehicles[vehicleid])
	    {
	    	new engine, lights, alarm, doors, bonnet, boot, objective;
	    	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		SetVehicleParamsEx(vehicleid, true, lights, alarm, doors, bonnet, boot, objective );
		}
Reply
#2

I'm not sure but I think you should take the vehicle model, not her id.

if(!EnginedVehicles[GetVehicleModel(vehicleid)])
Reply
#3

Quote:
Originally Posted by Florin48
Посмотреть сообщение
I'm not sure but I think you should take the vehicle model, not her id.

if(!EnginedVehicles[GetVehicleModel(vehicleid)])
It didn't work :3
Reply
#4

try now
PHP код:
stock EnginedVehicles(carid)
{
    switch(
GetVehicleModel(carid)) {
        case 
400..480482..500502..508511..554556..563565..568571..583585..589592593595..605609: return true;
    }
    return 
false;
}; 
use this stock, it was created now I hope it will go.
Reply
#5

Quote:
Originally Posted by Florin48
Посмотреть сообщение
try now
PHP код:
stock EnginedVehicles(carid)
{
    switch(
GetVehicleModel(carid)) {
        case 
400..480482..500502..508511..554556..563565..568571..583585..589592593595..605609: return true;
    }
    return 
false;
}; 
use this stock, it was created now I hope it will go.
Why stock? Don't abuse "stock" when you don't need it..
Reply
#6

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
Why stock? Don't abuse "stock" when you don't need it..
why not?
I use stock and "use" I say I need them.
Reply
#7

Quote:
Originally Posted by Florin48
Посмотреть сообщение
why not?
I use stock and "use" I say I need them.
You don't "need" them, Just remove the word "stock" and the function would work properly..

Read this.. https://sampforum.blast.hk/showthread.php?tid=570635
Reply
#8

Nothing works, i tried this way but it doesn't work either.
Код:
        new vehicleid;
        if(GetVehicleModel(vehicleid) == 481 || 509 || 510)
     	{
     		new engine, lights, alarm, doors, bonnet, boot, objective;
	    	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		SetVehicleParamsEx(vehicleid, true, lights, alarm, doors, bonnet, boot, objective );
	}
Reply
#9

Quote:
Originally Posted by Mike861
Посмотреть сообщение
Nothing works, i tried this way but it doesn't work either.
Код:
        new vehicleid;
        if(GetVehicleModel(vehicleid) == 481 || 509 || 510)
     	{
     		new engine, lights, alarm, doors, bonnet, boot, objective;
	    	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
		SetVehicleParamsEx(vehicleid, true, lights, alarm, doors, bonnet, boot, objective );
	}
481 || 509 || 510 is 1.If you want to check it using || (logical OR) you should go for something like this:
PHP код:
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 ||GetVehicleModel(vehicleid) == 510
or even
PHP код:
new tempidGetVehicleModel(vehicleid);
if(
tempid== 481 || tempid == 509 || tempid == 510
also
PHP код:
new vehicleid
you only declared the variable.you should give it some value.
PHP код:
new vehicleid GetPlayerVehicleID(playerid); 
but i would suggest use the function that someone posted above

PHP код:
EnginedVehicle(carid

    switch(
GetVehicleModel(carid)) 
    { 
        case 
400..480482..500502..508511..554556..563565..568571..583585..589592593595..605609: return true
    } 
    return 
false

and call the function
PHP код:
new vehicleid GetPlayerVehicleID(playerid);
if(
EnginedVehicle(vehicleid))
{
/*process*/

Reply
#10

Quote:
Originally Posted by SyS
Посмотреть сообщение
481 || 509 || 510 is 1.If you want to check it using || (logical OR) you should go for something like this:
PHP код:
if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 ||GetVehicleModel(vehicleid) == 510
or even
PHP код:
new tempidGetVehicleModel(vehicleid);
if(
tempid== 481 || tempid == 509 || tempid == 510
also
PHP код:
new vehicleid
you only declared the variable.you should give it some value.
PHP код:
new vehicleid GetPlayerVehicleID(playerid); 
but i would suggest use the function that someone posted above

PHP код:
EnginedVehicle(carid

    switch(
GetVehicleModel(carid)) 
    { 
        case 
400..480482..500502..508511..554556..563565..568571..583585..589592593595..605609: return true
    } 
    return 
false

and call the function
PHP код:
new vehicleid GetPlayerVehicleID(playerid);
if(
EnginedVehicle(vehicleid))
{
/*process*/

Thanks, +rep.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)