Help with OnVehicleStreamIn - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with OnVehicleStreamIn (
/showthread.php?tid=167934)
Help with OnVehicleStreamIn -
Mystique - 14.08.2010
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?
Re: Help with OnVehicleStreamIn -
[HUN]Jaki - 14.08.2010
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.
Re: Help with OnVehicleStreamIn -
ikey07 - 14.08.2010
Make some value for example CarLocked[MAX_VEHICLES];
and on stream in if Car Locked Setparams 1 else 0
Re: Help with OnVehicleStreamIn -
Mystique - 14.08.2010
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;
}
Re: Help with OnVehicleStreamIn -
[HUN]Jaki - 14.08.2010
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 );
}