SA-MP Forums Archive
Problem - 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: Problem (/showthread.php?tid=328124)



Problem - Face9000 - 23.03.2012

Hello,i've this small speedcap:

pawn Код:
public WantedLvlSpeed()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerSpeed(i, true) > 140.0 && TEAM_CIV)
        {
             new str[150];
             new plwl = GetPlayerWantedLevel(i);
             plwl = GetPlayerWantedLevel(i);
             SetPlayerWantedLevel(i,plwl +1);
             format(str,150,"- CRIME - Speed Limit Passed! (140 km/h) - You're going at %d km/h - Wanted Level: %d",GetPlayerSpeed(i,true),plwl);
             SendClientMessage(i,red,str);
             return 1;
        }
    }
    return 1;
}


But i've a problem,the speedcap works but with a little thing i need to fix. If a cop pass the 140km/h limit,he will get a wanted star.How to avoid that?

I want ONLY TEAM_CIV get's wanted stars and not TEAM_COP

Thanks.


Re: Problem - .FuneraL. - 23.03.2012

Try not to set a single time, remove the definition, thus :

pawn Код:
public WantedLvlSpeed()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerSpeed(i, true) > 140.0)
        {
             new str[150];
             new plwl = GetPlayerWantedLevel(i);
             plwl = GetPlayerWantedLevel(i);
             SetPlayerWantedLevel(i,plwl +1);
             format(str,150,"- CRIME - Speed Limit Passed! (140 km/h) - You're going at %d km/h - Wanted Level: %d",GetPlayerSpeed(i,true),plwl);
             SendClientMessage(i,red,str);
             return 1;
        }
    }
    return 1;
}



Re: Problem - IstuntmanI - 23.03.2012

Change
Код:
if(GetPlayerSpeed(i, true) > 140.0 && TEAM_CIV)
to
Код:
if(GetPlayerSpeed(i, true) > 140.0 && FactionVariable[ playerid ] == TEAM_CIV)
Change FactionVariable to the variable where you store player's faction.


Re: Problem - Babul - 23.03.2012

atm the TEAM_CIV is not included in any check. whats your playerid team enum? anyways, ima try:
pawn Код:
public WantedLvlSpeed()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerSpeed(i, true) > 140.0 && pInfo[playerid][pTeam]==TEAM_CIV)
        {
            new str[150];
            new plwl = GetPlayerWantedLevel(i);
            plwl = GetPlayerWantedLevel(i);
            SetPlayerWantedLevel(i,plwl +1);
            format(str,150,"- CRIME - Speed Limit Passed! (140 km/h) - You're going at %d km/h - Wanted Level: %d",GetPlayerSpeed(i,true),plwl);
            SendClientMessage(i,red,str);
            return 1;
        }
    }
    return 1;
}
edit: lol 3 answers @ same time


Re: Problem - T0pAz - 23.03.2012

Assuming you are using the SA-MP Team system.

pawn Код:
public WantedLvlSpeed()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerSpeed(i, true) > 140.0 && gTeam[i] == TEAM_CIV)
        {
             new str[150];
             new plwl = GetPlayerWantedLevel(i);
             plwl = GetPlayerWantedLevel(i);
             SetPlayerWantedLevel(i,plwl +1);
             format(str,150,"- CRIME - Speed Limit Passed! (140 km/h) - You're going at %d km/h - Wanted Level: %d",GetPlayerSpeed(i,true),plwl);
             SendClientMessage(i,red,str);
             return 1;
        }
    }
    return 1;
}



Re: Problem - Face9000 - 23.03.2012

Quote:
Originally Posted by .FuneraL.
Посмотреть сообщение
Try not to set a single time, remove the definition, thus :

pawn Код:
public WantedLvlSpeed()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerSpeed(i, true) > 140.0)
        {
             new str[150];
             new plwl = GetPlayerWantedLevel(i);
             plwl = GetPlayerWantedLevel(i);
             SetPlayerWantedLevel(i,plwl +1);
             format(str,150,"- CRIME - Speed Limit Passed! (140 km/h) - You're going at %d km/h - Wanted Level: %d",GetPlayerSpeed(i,true),plwl);
             SendClientMessage(i,red,str);
             return 1;
        }
    }
    return 1;
}
Nothing.

Quote:
Originally Posted by costel_nistor96
Посмотреть сообщение
Change
Код:
if(GetPlayerSpeed(i, true) > 140.0 && TEAM_CIV)
to
Код:
if(GetPlayerSpeed(i, true) > 140.0 && FactionVariable[ playerid ] == TEAM_CIV)
Change FactionVariable to the variable where you store player's faction.
FactionVariable?I use gTeam.

EDIT: T0pAz thanks,i'll try.