Some Script Bugging
#1

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
Reply
#2

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

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
Reply
#4

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
Reply
#5

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.
Reply
#6

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++
Reply
#7

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
Reply
#8

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

Hello Someone
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)