Respawning unused cars problem - 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: Respawning unused cars problem (
/showthread.php?tid=263646)
Respawning unused cars problem -
Tachibana - 22.06.2011
So here is a prob, I got cmd like that
pawn Код:
CMD:respawnveh(playerid, unused[])
{
if(PlayerInfo[playerid][Admin] < 4)
return SendClientMessage(playerid, COLOR_RED, "You are not a Public Safety Member! Or your PSM level is too low!");
SendClientMessageToAll(COLOR_RED, "All unused vehicles have been respawned by Public Safety Member!");
RespawnAllEmptyCars();
#pragma unused unused
for(new i; (++ i) != MAX_VEHICLES; ) {
SetVehicleToRespawn(i);
}
return true;
}
and here is
pawn Код:
//=============Respawn Vehs====================//
stock IsVehicleInUse(vid)
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerInVehicle(i, vid)) return 1;
}
return 0;
}
stock RespawnAllEmptyCars()
{
for(new i=0; i < 700; i++)
{
if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
}
}
//=============Respawn Vehs====================//
So this is suppose to respawn ONLY unused cars as I used "RespawnAllEmptyCars" but it respawns everycar even if player is inside them.
Any solution?
Re: Respawning unused cars problem -
dr.pepper - 22.06.2011
pawn Код:
stock RespawnAllEmptyCars()
{
for(new i=0; i < 700; i++)
{
if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
}
return 1;
}
Re: Respawning unused cars problem -
Tachibana - 22.06.2011
Quote:
Originally Posted by dr.pepper
pawn Код:
stock RespawnAllEmptyCars() { for(new i=0; i < 700; i++) { if(!IsVehicleInUse(i)) SetVehicleToRespawn(i); } return 1; }
|
Nope still respawns used cars
Re: Respawning unused cars problem -
Tachibana - 22.06.2011
Anyone got any ideas?
Re: Respawning unused cars problem -
PrawkC - 23.06.2011
pawn Код:
stock RespawnAllEmptyCars()
{
for(new i=0; i < 700; i++)
{
if(IsVehicleInUse(i) == 0) SetVehicleToRespawn(i);
}
}
Try that.
Re: Respawning unused cars problem -
Tachibana - 23.06.2011
Quote:
Originally Posted by PrawkC
pawn Код:
stock RespawnAllEmptyCars() { for(new i=0; i < 700; i++) { if(IsVehicleInUse(i) == 0) SetVehicleToRespawn(i); } }
Try that.
|
Nope it still respawns every car but I want only unused ones to be...
Re: Respawning unused cars problem -
=WoR=Varth - 23.06.2011
pawn Код:
//=============Respawn Vehs====================//
stock IsVehicleInUse(vid)
{
for(new i=0;i<GetMaxPlayers();i++)
{
if(IsPlayerInVehicle(i,vid)) return 1;
}
return 0;
}
stock RespawnAllEmptyCars()
{
for(new i=1;i<MAX_VEHICLES;i++)
{
if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
}
}
//=============Respawn Vehs====================//
Not tested.
Use "Usefull Function to make it easier.
Re: Respawning unused cars problem -
Tachibana - 23.06.2011
Quote:
Originally Posted by varthshenon
pawn Код:
//=============Respawn Vehs====================// stock IsVehicleInUse(vid) { for(new i=0;i<GetMaxPlayers();i++) { if(IsPlayerInVehicle(i,vid)) return 1; } return 0; }
stock RespawnAllEmptyCars() { for(new i=1;i<MAX_VEHICLES;i++) { if(!IsVehicleInUse(i)) SetVehicleToRespawn(i); } } //=============Respawn Vehs====================//
Not tested.
Use "Usefull Function to make it easier.
|
Still nothing but faster respawn than others...
Re: Respawning unused cars problem -
Donya - 23.06.2011
pawn Код:
CMD:vrespawn(playerid, params[])
{
#pragma unused params
if(!IsPlayerAdmin(playerid)) return 0;
new bool:VehicleUsed[MAX_VEHICLES] = false;
foreach(Character, i)//for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInAnyVehicle(i)) VehicleUsed[GetPlayerVehicleID(i)] = true;
}
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(VehicleUsed[i] == false) SetVehicleToRespawn(i);
}
return SendClientMessageToAll(COLOR_YELLOW,"All Unccupied Vehicles Have Been Respawned");
}
Re: Respawning unused cars problem -
Tachibana - 23.06.2011
Quote:
Originally Posted by Donya
pawn Код:
CMD:vrespawn(playerid, params[]) { #pragma unused params if(!IsPlayerAdmin(playerid)) return 0; new bool:VehicleUsed[MAX_VEHICLES] = false; foreach(Character, i)//for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerInAnyVehicle(i)) VehicleUsed[GetPlayerVehicleID(i)] = true; } for(new i = 0; i < MAX_VEHICLES; i++) { if(VehicleUsed[i] == false) SetVehicleToRespawn(i); } return SendClientMessageToAll(COLOR_YELLOW,"All Unccupied Vehicles Have Been Respawned"); }
|
And we got a winner! that one works!
Tho if possible could you explain to me what was wrong and what was needed to change? :O