[HELP] system vehicle
#1

Hi boys,

I have modiefed a system vehicle. (Available on sa:mp/fs)

When the player to connect on the server with the command /v get, he can to create this vehicle ( createvehicle) and when he want to destroy the vehicle he made /v destroy.

OK, work's fine.

But I want to create one system when there are a payday system will check through all vehicles, and despawn those which have owners offline and are not driven by anyone. I don't to success to made that. Player offline so not id. Maybe look if VehicleInfo[vehi][vOwner] and if sendername is not connected...


Thank for help

Bye.
Reply
#2

when payday comes just do this:
Код:
if(!IsPlayerConnected(Cars[i][cOwner]))
{
SetVehicleToRespawn(i);
}
Reply
#3

Depends.. if cOwner is determined by name or a MySQL ID.

If its by name, you need to GetPlayerName then check if the name is equal to an online player's name, but using a loop such as

pawn Код:
for(new i = 0; i <= MAX_PLAYERS; i++)
Reply
#4

no dont work.

When i create a vehicle, it's veh1[playerid] = CreateVehicle(...)

if i made that:

public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(veh1[playerid]);
return 1;
}

work's perfectly. But i want in the payday, so for to test i use /test command.


Код:
if(!strcmp(cmd,"/test",true))
 {
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
		  if(!IsPlayerConnected(veh1[i]))
 	 	  {
			DestroyVehicle(veh1[i]);
		  }
		}
 }
dont' work...
Reply
#5

why you have if(!strcmp ...

use this..

pawn Код:
if(!strcmp(cmd,"/test",true))
 {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
          if(!IsPlayerConnected(veh1[i]))
          {
            DestroyVehicle(veh1[i]);
          }
        }
 }
Reply
#6

Similar no?
Reply
#7

Quote:
Originally Posted by Antonio (eternalrp.webatu.com)
why you have if(!strcmp ...

use this..

pawn Код:
if(!strcmp(cmd,"/test",true))
 {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
          if(!IsPlayerConnected(veh1[i]))
          {
            DestroyVehicle(veh1[i]);
          }
        }
 }
You did the same exact thing Homer_Jeferson did.
Reply
#8

Shit.. I did

Try THIS...

pawn Код:
if(strcmp(cmd,"/test",true))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(veh1[i]))
{
DestroyVehicle(veh1[i]);
}
}
}
if that does't work, you may want to try this..


pawn Код:
if(strcmp(cmd,"/test",true))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(veh1[i]))
{
SetVehicleToRespawn(veh1[i]);
}
}
}
Ahh, those wont work. See what I realised is what your doing is looking for if(!IsPlayerConnected(veh1[i])) which won't work because 'veh1' is a car, not a person.
Reply
#9

See, what you need to do is make a sort of variable type thing for all vehicles.

At TOP of script
pawn Код:
new vOwner[MAX_VEHICLES];
Then when you do 'veh1[playerid] = CreateVehicle(...)' or w/e, underneath that, create a line like this...
pawn Код:
vOwner[vehicleid] = playerid;
And you /test command should look like this..
pawn Код:
if(strcmp(cmd,"/test",true))
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
if(vOwner[v] == INVALID_PLAYER_ID)
{
DestroyVehicle(veh1[i]);
}
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)