Help with OnVehicleStreamIn
#1

Hello, I'm experiencing some problems with the carlock. It all works fine if I'm close to the vehicle and then type /carlock. It locks the vehicle and you can unlock it again with /carlock. Now when I go away and then come back (streaming out and in) I can't get the carlock off.
Does anyone have solutiond on this?
Reply
#2

Show us your /carlock command!
The problem might be that you don't store the id of the player who can unlock it, but I don't know actually.
Reply
#3

Make some value for example CarLocked[MAX_VEHICLES];

and on stream in if Car Locked Setparams 1 else 0
Reply
#4

This is my /carlock command.
pawn Код:
if(strcmp(cmd, "/carlock", true) ==0)
    {
     if(GetClosestVehicle(playerid, 5))
     {
      for(new i = 0; i < MAX_PLAYERS; i++)
      {
       if(strmatch(CarSystem[GetCreatorID(vehicleid)][Carowner],pName(playerid)))
       {
        if(CarLock[GetClosestVehicle(playerid,5)] == 0)
        {
        CarLock[GetClosestVehicle(playerid,5)] = 1;
        SetVehicleParamsForPlayer(GetClosestVehicle(playerid,5),i,0,1);
        new str[128];
        format(str, sizeof(str), "*%s presses a key which locks the doors of the vehicle", pName(playerid));
        ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHAT,MECHAT,MECHAT);
        return 1;
        }
        else if(CarLock[GetClosestVehicle(playerid,5)] == 1)
        {
        CarLock[GetClosestVehicle(playerid,5)] = 0;
        SetVehicleParamsForPlayer(GetClosestVehicle(playerid,5),i,0,0);
        new str[128];
        format(str, sizeof(str), "*%s presses a key which unlocks the doors of the vehicle", pName(playerid));
        ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHAT,MECHAT,MECHAT);
        return 1;
        }
       }

      }
     }
     return 1;
     }

And this is my OnVehicleStreamIn:

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    for(new i = 0;i<MAX_CARS;i++)
    {
    SetVehicleParamsForPlayer(i, forplayerid, 0, CarLock[i]);
    }
    return 1;
}
Reply
#5

Yes, it should be something like:
Код:
new CarLocked[MAX_VEHICLES];

if (/carlock) CarLocked[GetPlayerVehicleID(playerid)]=playerid;

if (/unlock && CarLocked[vehicleid]==playerid) CarLocked[vehicleid]=-1;

OnVehicleStreamIn(){
  if (CarLocked[vehicleid]!=-1) SetVehicleParams( locked );
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)