SA-MP Forums Archive
Some Script Bugging - 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: Some Script Bugging (/showthread.php?tid=588164)



Some Script Bugging - Harith - 06.09.2015

Hi Guys Im Making A Police System But Some Script Are Bugging
OnPlayerSpawn
Quote:

if(GetPlayerSkin(playerid) == 280 || 281 || 282 || 283 || 284 || 285 || 286 || 288 || 300 || 301 || 302 )
{
if(!AccInfo[playerid][Police]) return GameTextForPlayer(playerid,"~r~This Skin Is For~n~Police~n~Only",4000,1);
}

OnPlayerState
Quote:

new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleModel(vehicleid);
if(GetVehicleModel(vehicleid) == 599 || 596 || 597 || 598 || 497 || 520 || 528 || 425 || 427 || 523 || 490)
{
if(!AccInfo[playerid][Police])
{
RemovePlayerFromVehicle(playerid);
GameTextForPlayer(playerid, "~r~Police Only!", 1000, 5);
}
}

When I'm Using This Script And Spawn A Car All Car And Skin It Will Show A Gametext Police Only Any Idea? Please Help Me


Re: Some Script Bugging - Amizone - 06.09.2015

This has to do something with variable Police.You sure you reset it when a new account is created?


Re: Some Script Bugging - Harith - 06.09.2015

Quote:
Originally Posted by Amizone
Посмотреть сообщение
This has to do something with variable Police.You sure you reset it when a new account is created?
Wait Let Me Try


Re: Some Script Bugging - Harith - 06.09.2015

Quote:
Originally Posted by Amizone
Посмотреть сообщение
This has to do something with variable Police.You sure you reset it when a new account is created?
Still Same


Re: Some Script Bugging - iggy1 - 06.09.2015

Your 'if' statement is incorrect.

Код:
if(GetPlayerSkin(playerid) == 280 || 281 || 282 || 283 || 284 || 285 || 286 || 288 || 300 || 301 || 302 )
Should be

Код:
new SkinID = GetPlayerSkin(playerid);
if( SkinID == 280 || SkinID == 281 || SkinID == 282 /* And so on**/ )
You must compare with the skin id, otherwise you are just checking if the numbers are non-zero.

Your original code checks if SkinID is '280' the rest of it checks if 281 ... 302 is non-zero - which it is.


Re: Some Script Bugging - Harith - 06.09.2015

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Your 'if' statement is incorrect.

Код:
if(GetPlayerSkin(playerid) == 280 || 281 || 282 || 283 || 284 || 285 || 286 || 288 || 300 || 301 || 302 )
Should be

Код:
new SkinID = GetPlayerSkin(playerid);
if( SkinID == 280 || SkinID == 281 || SkinID == 282 /* And so on**/ )
You must compare with the skin id, otherwise you are just checking if the numbers are non-zero.

Your original code checks if SkinID is '280' the rest of it checks if 281 ... 302 is non-zero - which it is.
Nice!! REP++


Re: Some Script Bugging - Harith - 06.09.2015

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Your 'if' statement is incorrect.

Код:
if(GetPlayerSkin(playerid) == 280 || 281 || 282 || 283 || 284 || 285 || 286 || 288 || 300 || 301 || 302 )
Should be

Код:
new SkinID = GetPlayerSkin(playerid);
if( SkinID == 280 || SkinID == 281 || SkinID == 282 /* And so on**/ )
You must compare with the skin id, otherwise you are just checking if the numbers are non-zero.

Your original code checks if SkinID is '280' the rest of it checks if 281 ... 302 is non-zero - which it is.
Will It Work OnPlayerState With Same Method But GetPlayerVehicleID


Re: Some Script Bugging - iggy1 - 06.09.2015

Same whenever you wish to compare multiple values in an 'if' statement. So yes use it there too.


Re: Some Script Bugging - Harith - 06.09.2015

Hello Someone


Re: Some Script Bugging - iggy1 - 06.09.2015

You could try locking the doors so they can't even attempt. By locking the doors when the vehicle is streamed in.

Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    switch( GetVehicleModel(vehicleid) )
    {
        case 599, 596, 597, 598, 497, 520, 528, 425, 427, 532, 490:
        {
            if (!AccInfo[forplayerid][Police])
                SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
            else
                SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 0);
        }	
    }
    return 1;
}
Tidied up a bit by using switch.