SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Undefined String Error Please Help! (https://forum.sa-mp.com/showthread.php?t=671863)

Eyex 16/01/2020 03:14 PM

Undefined String Error Please Help!
 
Thiy is my code.

//Autoszerelohoz
for(new x;x<sizeof(MechVehicles);x++) {
format(string, sizeof(string), "MECHANIC %d", MechVehicles[x]);
SetVehicleNumberPlate(MechVehicles[x], string);
SetVehicleToRespawn(MechVehicles[x]);
}

Code:

C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(653) : error 017: undefined symbol "string"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(653) : error 017: undefined symbol "string"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(653) : error 029: invalid expression, assumed zero
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(653) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664                          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Please help

Radless 16/01/2020 03:44 PM

Re: Undefined String Error Please Help!
 
new string[128];
for(new x;x<sizeof(MechVehicles);x++) {
format(string, sizeof(string), "MECHANIC %d", MechVehicles[x]);
SetVehicleNumberPlate(MechVehicles[x], string);
SetVehicleToRespawn(MechVehicles[x]);
}

Yasef99 16/01/2020 03:44 PM

Re: Undefined String Error Please Help!
 
//Autoszerelohoz
for(new x;x<sizeof(MechVehicles);x++) {
new string[124]; //Change the Size(124)
format(string, sizeof(string), "MECHANIC %d", MechVehicles[x]);
SetVehicleNumberPlate(MechVehicles[x], string);
SetVehicleToRespawn(MechVehicles[x]);
}

Eyex 16/01/2020 03:48 PM

Re: Undefined String Error Please Help!
 
Quote:

C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 017: undefined symbol "string"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : warning 215: expression has no effect
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 001: expected token: ";", but found "]"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : fatal error 107: too many error messages on one line
Now.. :/ im try [128]; [256]; but dont work

Eyex 16/01/2020 03:50 PM

Re: Undefined String Error Please Help!
 
Quote:

for(new x;x<sizeof(MechVehicles);x++){
new string[124];
format(string; sizeof(string), "MECHANIC %d", MechVehicles[x]);
SetVehicleNumberPlate(MechVehicles[x],);
SetVehicleToRespawn(MechVehicles[x]);
}
Quote:

C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 001: expected token: ",", but found ";"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : warning 215: expression has no effect
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : warning 215: expression has no effect
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : warning 215: expression has no effect
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 001: expected token: ";", but found ")"
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : error 029: invalid expression, assumed zero
C:\Users\Eyex\Desktop\NA-RP\gamemodes\rcrp.pwn(656) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Do I need to define String at the beginning of the mode?

Yasef99 16/01/2020 05:26 PM

Re: Undefined String Error Please Help!
 
for(new x;x<sizeof(MechVehicles);x++){
new string[124];
format(string, sizeof(string), "MECHANIC %d", MechVehicles[x]); //You put "format(string; sizeof....." is string, sizeof...
SetVehicleNumberPlate(MechVehicles[x],);
SetVehicleToRespawn(MechVehicles[x]);
}

SiaReyes 16/01/2020 08:04 PM

Re: Undefined String Error Please Help!
 
declare the:
Code:

new string[124];
outside the loop


All times are GMT. The time now is 05:35 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.