[HELP] system vehicle -
nico005 - 31.05.2010
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.
Re: [HELP] system vehicle -
coole210 - 01.06.2010
when payday comes just do this:
Код:
if(!IsPlayerConnected(Cars[i][cOwner]))
{
SetVehicleToRespawn(i);
}
Re: [HELP] system vehicle -
Antonio [G-RP] - 01.06.2010
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++)
Re: [HELP] system vehicle -
nico005 - 02.06.2010
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...
Re: [HELP] system vehicle -
Antonio [G-RP] - 02.06.2010
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]);
}
}
}
Re: [HELP] system vehicle -
nico005 - 02.06.2010
Similar no?
Re: [HELP] system vehicle -
Carlton - 02.06.2010
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.
Re: [HELP] system vehicle -
Antonio [G-RP] - 02.06.2010
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.
Re: [HELP] system vehicle -
Antonio [G-RP] - 02.06.2010
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]);
}
}
}