/vrespawn - 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: /vrespawn (
/showthread.php?tid=165350)
/vrespawn -
Dolph - 04.08.2010
Since I'm fairly new to loops, I wanted to make a /vrespawn that respawns all unoccupied vehicles.
Here is the code:
pawn Код:
dcmd_vrespawn(playerid,params[])
{
#pragma unused params
if(pi[playerid][admin] <= 0) return 0;
if(sscanf(params,"u"))
{
for(new 1 = 0; i < MAX_VEHICLES; i++)
{
SendClientMessageToAll(COLOUR_YELLOW,"All unoccupied vehicles has been respawned");
SetVehicleToRespawn(i);
return 1;
}
return 1;
}
Errors:
Код:
C:\GTASER~1\GAMEMO~1\MyDm.pwn(1860) : error 001: expected token: "-identifier-", but found "-integer value-"
C:\GTASER~1\GAMEMO~1\MyDm.pwn(1862) : error 008: must be a constant expression; assumed zero
C:\GTASER~1\GAMEMO~1\MyDm.pwn(1863) : error 001: expected token: ")", but found ";"
C:\GTASER~1\GAMEMO~1\MyDm.pwn(1863) : error 036: empty statement
Could someone tell me what I've done wrong?
Re: /vrespawn -
Jeffry - 04.08.2010
Try:
pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++)
Re: /vrespawn -
Mike Garber - 04.08.2010
No, since vehicle ID's start with 1, it should be;
pawn Код:
for(new i = 1; i < MAX_VEHICLES; i++)
Re: /vrespawn -
Dolph - 04.08.2010
Lol.. I actually saw the error now: for(new i = 0; i < MAX_VEHICLES; i++) I wrote new 1..
Thanks for the help!
EDIT:
pawn Код:
dcmd_vrespawn(playerid,params[])
{
#pragma unused params
if(pi[playerid][admin] <= 0) return 0;
if(sscanf(params,"u"))
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
SendClientMessageToAll(COLOUR_YELLOW,"All unoccupied vehicles has been respawned");
SetVehicleToRespawn(i);
return 1;
}
}
return 1;
}
Thats the code now.. The ClientMessage is being sent, but the vehicles doesnt respawn. Whats the problem now?
Re: /vrespawn -
Dolph - 04.08.2010
I don't mean to bump, but if I don't, this topic will probably die.
Re: /vrespawn -
Hiddos - 04.08.2010
pawn Код:
dcmd_vrespawn(playerid,params[])
{
#pragma unused params
if(pi[playerid][admin] <= 0) return 0;
if(sscanf(params,"u"))
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
SendClientMessageToAll(COLOUR_YELLOW,"All unoccupied vehicles has been respawned");
}
return 1;
}
Re: /vrespawn -
Mike Garber - 04.08.2010
As I said, vehicle ID's start with 1, so
pawn Код:
for(new i = 1; i < MAX_VEHICLES; i++)
Re: /vrespawn -
Hiddos - 04.08.2010
Oh well, whatever. Even I learned something today.
Re: /vrespawn -
Jeffry - 04.08.2010
Quote:
Originally Posted by Hiddos
Oh well, whatever. Even I learned something today.
|
Same here.
Re: /vrespawn -
Nero_3D - 04.08.2010
pawn Код:
dcmd_vrespawn(playerid, params[]) {
#pragma unused params
if(pi[playerid][admin] > 0) {
new bool:VehicleUsed[MAX_VEHICLES], i;
for( ; i != MAX_PLAYERS; i++) {
if(IsPlayerInAnyVehicle(i)) {
VehicleUsed[GetPlayerVehicleID(playerid)] = true;
}
}
for(i = 1; i != MAX_VEHICLES; i++) {
if(VehicleUsed[i] == false) {
SetVehicleToRespawn(i);
}
}
return SendClientMessageToAll(COLOUR_YELLOW,"All unoccupied vehicles has been respawned");
}
return 0;
}