SA-MP Forums Archive
What wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What wrong? (/showthread.php?tid=306985)



What wrong? - Gooday - 28.12.2011

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger && GetVehicleModel(vehicleid) == 525)
{
    if(GetPlayerSkin(playerid) != 50)
        ClearAnimations(playerid);
    return 1;
}
if(!ispassenger && GetVehicleModel(vehicleid) == 596)
{
    if(GetPlayerSkin(playerid) != 282)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 596)
{
    if(GetPlayerSkin(playerid) != 283)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 596)
{
    if(GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 597)
{
    if(GetPlayerSkin(playerid) != 282)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 597)
{
    if(GetPlayerSkin(playerid) != 283)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 597)
{
    if(GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 597)
{
    if(GetPlayerSkin(playerid) != 288)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 598)
{
    if(GetPlayerSkin(playerid) != 282)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 598)
{
    if(GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 598)
{
    if(GetPlayerSkin(playerid) != 283)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 598)
{
    if(GetPlayerSkin(playerid) != 288)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 490)
{
    if(GetPlayerSkin(playerid) != 282)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 490)
{
    if(GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 490)
{
    if(GetPlayerSkin(playerid) != 288)
        ClearAnimations(playerid);
}if(!ispassenger && GetVehicleModel(vehicleid) == 490)
{
    if(GetPlayerSkin(playerid) != 283)
        ClearAnimations(playerid);
}
if(!ispassenger && GetVehicleModel(vehicleid) == 427)
{
    if(GetPlayerSkin(playerid) != 282)
        ClearAnimations(playerid);
}if(!ispassenger && GetVehicleModel(vehicleid) == 427)
{
    if(GetPlayerSkin(playerid) != 283)
        ClearAnimations(playerid);
}if(!ispassenger && GetVehicleModel(vehicleid) == 427)
{
    if(GetPlayerSkin(playerid) != 288)
        ClearAnimations(playerid);
}if(!ispassenger && GetVehicleModel(vehicleid) == 427)
{
    if(GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
}
    return 1;
}
I cant enter the vehicle if i got the skin i got no errors by compiling...please help


Re: What wrong? - Gh05t_ - 28.12.2011

Each if statement is evaluated, so once the condition is true the code within the local scope is executed. If false, the check is then passed to the next statement and continues until a check if verified. Code optimization referrers to altering code, to make it more efficient for use. I've made a minor optimization to your code. Since each one of your if statements contains an if(!ispassenger) check, it may be called once. This allows multiple checks without reference to that specific check.


pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(GetVehicleModel(vehicleid) == 525) if(GetPlayerSkin(playerid) != 50)
        if(GetVehicleModel(vehicleid) == 596) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281)
        if(GetVehicleModel(vehicleid) == 597) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288)
        if(GetVehicleModel(vehicleid) == 598) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288)
        if(GetVehicleModel(vehicleid) == 490) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 281 || GetPlayerSkin(playerid) != 288 || GetPlayerSkin(playerid) != 283)
        if(GetVehicleModel(vehicleid) == 427) if(GetPlayerSkin(playerid) != 282 || GetPlayerSkin(playerid) != 283 || GetPlayerSkin(playerid) != 288 || GetPlayerSkin(playerid) != 281)
        ClearAnimations(playerid);
    }
    return true;
}
Quote:
Originally Posted by Gooday
Посмотреть сообщение
I cant enter the vehicle if i got the skin i got no errors by compiling...please help
You must be in a vehicle and skin other than the id's listed.


Re: What wrong? - Gooday - 28.12.2011

Still not working