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



Cars - nezo2001 - 14.12.2014

Hello i want
PHP код:
 if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER
If the car belong to TEAM_GS and the player doesn't belong to that team force the player to go out from the car.
Please Help [REP ++]


Re: Cars - SickAttack - 14.12.2014

Example:

pawn Код:
new vTeamGS;

public OnGameModeInit()
{
    vTeamGS = AddStaticVehicleEx(432, 2729.6108, -2435.5110, 13.6465, 270.4632, 43, 0, 900);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        if(gTeam[playerid] != TEAM_GS && GetPlayerVehicleID(playerid) == vTeamGS) RemovePlayerFromVehicle(playerid);
    }
}



Re: Cars - semara123 - 14.12.2014

try to visit this link : https://sampforum.blast.hk/showthread.php?tid=160810

+rep plss if helpful


and try to search before post(if i'm right)

sorry for my bad english


Re: Cars - Lawbringer - 14.12.2014

It's a pretty simple thing, right?

First, find the callback you're going to be using. Probably OnPlayerStateChange. You want to compare for, like you already have, PLAYER_STATE_ONFOOT going to PLAYER_STATE_DRIVER. Add a check for teams.

Second, read this: https://sampwiki.blast.hk/wiki/ClearAnimations
- ClearAnimations(playerid) will stop the animation of getting in the car so the State won't change.

So...
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
         new veh = GetPlayerVehicleID(playerid);
         if((VehicleInfo[vehicleid][vteam] != 0) && (VehicleInfo[vehicleid][vteam] != PlayerInfo[playerid][pteam]))
         {
                 SendClientMessage(playerid,-1,"This vehicle is restricted.");
                 ClearAnimations(playerid);
         }
    }
    return 1;
}



Re: Cars - nezo2001 - 14.12.2014

BTW i have solved it before looking on my post again but [REP ++] for all