Jump to content
  • 0

pomoc Respawn áut


Arthom

Dotaz

Ahojte, tak po dlhej dobe som sa vrátil k pawnu a tomuto fórku :33
 
Trošku som sa nudil a skúšal som všetky funkcie, aby som si na to spomenul, no našiel som brzdu.
Chcem respawnúť autá, no bohužiaľ mi to vypisuje chybu :d keď nerozumiem prečo (zabudol som :d)
 
Kód:

forward RespawnSpawnCar();
public RespawnSpawnCar() {
    new adr[128];
    for(new i = 1; i <= 15; i++) {
	format(adr, sizeof(adr), "Car%d", i);
	SetVehicleToRespawn(CarSpawn[adr]);
    }
}

a ako vytváram autá:

CarSpawn[Car1] = CreateVehicle(549,1158.5162000,-2024.6917000,518.2526000,359.4247000,72,39,15); //Tampa
CarSpawn[Car2] = CreateVehicle(598,1142.4762000,-2009.5929000,518.3005000,179.6942000,-1,1,15); //Police Car (LVPD)
CarSpawn[Car3] = CreateVehicle(599,1158.8741000,-1997.8960000,518.7469000,359.6764000,-1,1,15); //Police Ranger
CarSpawn[Car4] = CreateVehicle(420,1158.9023000,-2010.4873000,518.3337000,0.8347000,6,1,15); //Taxi
CarSpawn[Car5] = CreateVehicle(400,1142.5833000,-1997.1256000,518.6479000,179.0043000,123,1,15); //Landstalker
CarSpawn[Car6] = CreateVehicle(470,1159.0369000,-1984.5239000,518.5485000,359.3164000,43,-1,15); //Patriot
CarSpawn[Car7] = CreateVehicle(600,1142.6167000,-1983.9783000,518.2687000,179.5893000,32,8,15); //Picador
CarSpawn[Car8] = CreateVehicle(587,1158.9503000,-1970.3331000,518.2813000,0.8270000,40,1,15); //Euros
CarSpawn[Car9] = CreateVehicle(562,1142.6813000,-1969.5380000,518.2153000,179.7569000,35,1,15); //Elegy
CarSpawn[Car10] = CreateVehicle(411,1158.3159000,-1970.8728000,526.0325000,0.0764000,64,1,15); //Infernus
CarSpawn[Car11] = CreateVehicle(506,1142.9924000,-1970.6006000,526.0097000,180.4393000,6,6,15); //Super GT
CarSpawn[Car12] = CreateVehicle(451,1142.7291000,-1984.5532000,526.0121000,179.8849000,125,125,15); //Turismo
CarSpawn[Car13] = CreateVehicle(541,1158.2982000,-1997.7428000,525.9301000,359.7200000,58,8,15); //Bullet
CarSpawn[Car14] = CreateVehicle(429,1142.7211000,-1996.0244000,525.9850000,180.5895000,13,13,15); //Banshee
CarSpawn[Car15] = CreateVehicle(477,1158.3226000,-1984.8171000,526.0598000,359.5164000,94,1,15); //ZR-350

Vedeli by ste mi pomôcť? Ďakujem :)

Link to comment
Share on other sites

12 odpovědí na tuto otázku

Recommended Posts

  • 0

čo takto tá chyba? 

 

ale chyba je  CarSpawn[adr]

 

pretože adr je string nie integer a tam musí byť integer keďže to je vehicleid...a v tomto prípade mi príde aj blbosť robiť strval(); keďýe adr obdahuje aj písmenka a nie čísla...takže zrejme to vymeň za i alebo neviem ako si to predstavuješ

Link to comment
Share on other sites

  • 0
SetVehicleToRespawn(CarSpawn[adr]);

pole, musíš indexovať integerom, nie stringom

napr:

for(new i = 0; i < 15; i++) {

    SetVehicleToRespawn(CarSpawn[i]);  // samozrejme pokiaľ má pole minimálne 15 buniek [index 0-14]

}

Link to comment
Share on other sites

  • 0

tak v enume nemôžem mať čisto iba čísla (som skúšal), preto to robím takto a potrebujem aby to bolo vo formáte Car(cislo) tak ako to mám Car%d

Link to comment
Share on other sites

  • 0

to viem, ale som chcel rovno kód :d pretože mne sa to nejak nedarí :d

forward RespawnSpawnCar();
public RespawnSpawnCar() {
    new adr[128];
	for(new i = 1; i <= 15; i++) {
	    format(adr, sizeof(adr), "Car%d", i);
	    new test = strval(adr);
	    SetVehicleToRespawn(CarSpawn[test]); /* riadok 472 */
	}
}

a chyba:

F:\samp03z_svr_R1_win32\gamemodes\test.pwn(472) : warning 213: tag mismatch
Link to comment
Share on other sites

  • 0

Hore v ničom mám globálnu premenu

new CarSpawn[15];

Ako to mám spravené:

forward RespawnSpawnCar();
public RespawnSpawnCar() {
   for(new i = 1; i <= 15; i++) {
      SetVehicleToRespawn(CarSpawn[i]);
   }
}

Autá:

CarSpawn[1] = CreateVehicle(549,1158.5162000,-2024.6917000,518.2526000,359.4247000,72,39,15); //Tampa
CarSpawn[2] = CreateVehicle(598,1142.4762000,-2009.5929000,518.3005000,179.6942000,-1,1,15); //Police Car (LVPD)
CarSpawn[3] = CreateVehicle(599,1158.8741000,-1997.8960000,518.7469000,359.6764000,-1,1,15); //Police Ranger
CarSpawn[4] = CreateVehicle(420,1158.9023000,-2010.4873000,518.3337000,0.8347000,6,1,15); //Taxi
CarSpawn[5] = CreateVehicle(400,1142.5833000,-1997.1256000,518.6479000,179.0043000,123,1,15); //Landstalker
CarSpawn[6] = CreateVehicle(470,1159.0369000,-1984.5239000,518.5485000,359.3164000,43,-1,15); //Patriot
CarSpawn[7] = CreateVehicle(600,1142.6167000,-1983.9783000,518.2687000,179.5893000,32,8,15); //Picador
CarSpawn[8] = CreateVehicle(587,1158.9503000,-1970.3331000,518.2813000,0.8270000,40,1,15); //Euros
CarSpawn[9] = CreateVehicle(562,1142.6813000,-1969.5380000,518.2153000,179.7569000,35,1,15); //Elegy
CarSpawn[10] = CreateVehicle(411,1158.3159000,-1970.8728000,526.0325000,0.0764000,64,1,15); //Infernus
CarSpawn[11] = CreateVehicle(506,1142.9924000,-1970.6006000,526.0097000,180.4393000,6,6,15); //Super GT
CarSpawn[12] = CreateVehicle(451,1142.7291000,-1984.5532000,526.0121000,179.8849000,125,125,15); //Turismo
CarSpawn[13] = CreateVehicle(541,1158.2982000,-1997.7428000,525.9301000,359.7200000,58,8,15); //Bullet
CarSpawn[14] = CreateVehicle(429,1142.7211000,-1996.0244000,525.9850000,180.5895000,13,13,15); //Banshee
CarSpawn[15] = CreateVehicle(477,1158.3226000,-1984.8171000,526.0598000,359.5164000,94,1,15); //ZR-350

Chyby:

F:\samp03z_svr_R1_win32\gamemodes\test.pwn(196) : error 032: array index out of bounds (variable "CarSpawn")

 

Link to comment
Share on other sites

  • 0

začína sa 0 a končí 14


poprípadne lepšie spravíš takto:

 

#define MY_MAX_CARS

 

new Car[MY_MAX_CAR];

a do cyklus i <= MY_MAX_CAR

 

alebo ak nechceš define tak nechaj v new číslo a do cyklu sizeof(Car)

Link to comment
Share on other sites

  • 0

Super, už som to vyriešil :)

forward RespawnSpawnCar();
public RespawnSpawnCar() {
    for(new i = 0; i <= sizeof(CarSpawn); i++) {
        SetVehicleToRespawn(CarSpawn[i]);
    }
}

ďakujem za pomoc :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...