Car lock when owner is online
#1

Hello, I have a car ownership system inside my gamemode, and i tried to make the next thing.
Everytime a player connects, check if he has a car bought. If yes, lock the car automatically to all the players except him.
Everytime a player disconnects, check if he has a car bought. If yes, unlock the car automatically to all the players.
I used SetVehicleParamsForPlayer at the end of OnPlayerLogin callback (I'm using the register and login system from Godfather with some edits for my own gamemode) like this:
Код:
if(Info[playerid][eCarKeys] != 0)
{
	for(new i; i < MAX_PLAYERS; i++)
	{
	  if(i != playerid)
	  {
  		SetVehicleParamsForPlayer(Info[playerid][eCarKeys], i, 0, 1)
	  }
	}
}
And inside the OnPlayerDisconnect callback i used this:
Код:
if(Info[playerid][eCarKeys] != 0)
{
	for(new i; i < MAX_PLAYERS; i++)
	{
	  if(i != playerid)
	  {
  		SetVehicleParamsForPlayer(Info[playerid][eCarKeys], i, 0, 0)
	  }
	}
}
But, nothing happens. I mean, is not locking my car automatically after I login, and not unlocking my car after logout.
I tried with OnVehicleStreamIn too, but if I login and i'm not near the car, is not locking, and after disconnect if the car is locked, it remain locked.
I tried with Timers too, still nothing.
What else can I try or what i'm doing wrong, I don't have any more ideeas.

LE: Title changed ...
Reply
#2

Bump!
Reply
#3

Bump?! (another 12 hours passed)
Really no-one?
Reply
#4

Bump!
Reply
#5

Bump ...
Reply
#6

/lock command makes th eplaye rlock car if player uses it right
how about doing this

Код:
public onplayerconnect

you add this

for(new i; i < MAX_PLAYERS; i++)
	{
	  if(i != playerid)
	  {
  		SetVehicleParamsForPlayer(Info[playerid][eCarKeys], i, 0, 0)
	  }
	}
or what ever you will need to check the code but thats the idea for autolock on player connect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)