PDA

View Full Version : error 029: invalid expression, assumed zero


LazzyBoy
30/10/2017, 06:52 PM
else if(!strcmp(tmp, "unimpound", true, 7))
{
if(!strlen(tmp2) || !IsNumeric(tmp2) && PlayerInfo[playerid][playerteam] == FAC_TYPE_POLICE && PlayerInfo[playerid][ranklvl] <=2) return SCP(playerid, "car unimpound [ ID ]");
{
new theunimpoundid = strval(tmp2);
if(!dini_Isset(globalstats, "unimpoundslot"))
dini_IntSet(globalstats, "unimpoundslot", 0);
new ri = dini_Int(globalstats, "unimpoundslot");
if(ri >= sizeof(unimpoundpos))
{
ri = 0;
dini_IntSet(globalstats, "unimpoundslot", 0);
}
else dini_IntSet(globalstats, "unimpoundslot", ri+1);
VehicleInfo[theunimpoundid][vX] = unimpoundpos[ri][spawnx];
VehicleInfo[theunimpoundid][vY] = unimpoundpos[ri][spawny];
VehicleInfo[theunimpoundid][vZ] = unimpoundpos[ri][spawnz];
VehicleInfo[theunimpoundid][vA] = unimpoundpos[ri][sangle];
VehicleInfo[theunimpoundid][vVirtualWorld] = 0;
VehicleInfo[theunimpoundid][vImpounded] = 0;
VehicleInfo[theunimpoundid][vImpoundFee] = 0;
myStrcpy(VehicleInfo[theunimpoundid][vImpoundReason], "None");
ReloadVehicle(theunimpoundid);
printf("%d",theunimpoundid);
}
else //// ERROR Line
{
new iBigStr[1575], iCount, iSmllStr[128];
strcat(iBigStr, "Vehicle\tImpound fee\tImpound Reason\n");
VehicleLoop(v)
{
if(VehicleInfo[v][vActive] != true) continue;
if(strcmp(PlayerName(playerid), VehicleInfo[v][vOwner], false)) continue;
if(VehicleInfo[v][vImpounded] != 1) continue;
if(VehicleInfo[v][vImpounded] == 1 && VehicleInfo[v][vSpawned] != true)
{
iCount++;
format(iSmllStr, sizeof(iSmllStr), "%d %s(%d)\t%d\t%s\n", v, GetVehicleNameFromModel(VehicleInfo[v][vModel]),VehicleInfo[v][rID],VehicleInfo[v][vImpoundFee], VehicleInfo[v][vImpoundReason]);
}
strcat(iBigStr, iSmllStr);
ShowPlayerDialog(playerid, DIALOG_UNIMPOUND, DIALOG_STYLE_TABLIST_HEADERS, "{3196ef}Please select vehicle you would like to unimpound", iBigStr, "Select", "Exit");
}
if(!iCount) return SendClientError(playerid, "You don't have any impounded vehicle");
return 1;
}
}

error

error 029: invalid expression, assumed zero

Lucases
30/10/2017, 07:10 PM
Is that hard to use sscanf and zcmd?

LazzyBoy
30/10/2017, 07:11 PM
im using sscanf and zcmd already
the command is CAR which includes like 15 commands in it
like car lock / car unlock car unimpound etc so.

Konstantinos
30/10/2017, 07:13 PM
else dini_IntSet(globalstats, "unimpoundslot", ri + 1);

Your else statement ends there. What is the next else for? It doesn't have an if statement before unless you were supposed to have it as:

if (..)
{
}
else if (..)
{
}
else
{
}

LazzyBoy
30/10/2017, 07:18 PM
heres

if(!dini_Isset(globalstats, "unimpoundslot"))
dini_IntSet(globalstats, "unimpoundslot", 0);
new ri = dini_Int(globalstats, "unimpoundslot");
if(ri >= sizeof(unimpoundpos))
{
ri = 0;
dini_IntSet(globalstats, "unimpoundslot", 0);
}
else dini_IntSet(globalstats, "unimpoundslot", ri+1);

and the errors line should fit with this one

if(!strlen(tmp2) || !IsNumeric(tmp2) && PlayerInfo[playerid][playerteam] == FAC_TYPE_POLICE && PlayerInfo[playerid][ranklvl] <=2) return SCP(playerid, "car unimpound [ ID ]");
{

Konstantinos
30/10/2017, 07:28 PM
No, it doesn't fit with that line as you return an error so you basically open a new bracket out of nowhere and execute some code in it. This is your code:

if (...) return SCP(...);
{
// code.. that is ALWAYS executed
}
else // not an "if" pair before.
{
}

LazzyBoy
30/10/2017, 07:43 PM
Mind if you could help me a bit to fix the codes
i do understand how it works but in this code its pretty fuckd i'd say xD
Please

Konstantinos
30/10/2017, 07:50 PM
The code is indeed confusing and most here (including me) are not aware of what you're trying to do exactly. So let's break it into more pieces. When this code is supposed to be executed?

{
new theunimpoundid = strval(tmp2);
if (!dini_Isset(globalstats, "unimpoundslot"))
dini_IntSet(globalstats, "unimpoundslot", 0);
new ri = dini_Int(globalstats, "unimpoundslot");
if (ri >= sizeof(unimpoundpos))
{
ri = 0;
dini_IntSet(globalstats, "unimpoundslot", 0);
}
else dini_IntSet(globalstats, "unimpoundslot", ri + 1);
VehicleInfo[theunimpoundid][vX] = unimpoundpos[ri][spawnx];
VehicleInfo[theunimpoundid][vY] = unimpoundpos[ri][spawny];
VehicleInfo[theunimpoundid][vZ] = unimpoundpos[ri][spawnz];
VehicleInfo[theunimpoundid][vA] = unimpoundpos[ri][sangle];
VehicleInfo[theunimpoundid][vVirtualWorld] = 0;
VehicleInfo[theunimpoundid][vImpounded] = 0;
VehicleInfo[theunimpoundid][vImpoundFee] = 0;
myStrcpy(VehicleInfo[theunimpoundid][vImpoundReason], "None");
ReloadVehicle(theunimpoundid);
printf("%d", theunimpoundid);
}

LazzyBoy
30/10/2017, 10:39 PM
Okay so basiclly this command allows an player to unimpound his vehicle so as u can see there is two part of codes which ive scripted atleast i tried to make it right so
Now when a player writes the command it should show the dialog with the impounded vehicles which is the second script after the ELSE
When a police officer writes the command for example car unimpound it will show him the impounded vehicles that he owns but if he writes for example car unimpound ID(1) it will unimpound the id 1 vehicle which is the first script

hope you understand me and sorry for mistakes phone wroten

Konstantinos
30/10/2017, 10:50 PM
So if the cop input the ID, it will unimpound the vehicle, otherwise it will just show the dialog for either cop or player?


else if (!strcmp(tmp, "unimpound", true, 7))
{
if (strlen(tmp2) && IsNumeric(tmp2) && PlayerInfo[playerid][playerteam] == FAC_TYPE_POLICE && PlayerInfo[playerid][ranklvl] <= 2)
{
new theunimpoundid = strval(tmp2);
if (!dini_Isset(globalstats, "unimpoundslot"))
dini_IntSet(globalstats, "unimpoundslot", 0);

new ri = dini_Int(globalstats, "unimpoundslot");
if (ri >= sizeof(unimpoundpos))
{
ri = 0;
dini_IntSet(globalstats, "unimpoundslot", 0);
}
else dini_IntSet(globalstats, "unimpoundslot", ri + 1);

VehicleInfo[theunimpoundid][vX] = unimpoundpos[ri][spawnx];
VehicleInfo[theunimpoundid][vY] = unimpoundpos[ri][spawny];
VehicleInfo[theunimpoundid][vZ] = unimpoundpos[ri][spawnz];
VehicleInfo[theunimpoundid][vA] = unimpoundpos[ri][sangle];
VehicleInfo[theunimpoundid][vVirtualWorld] = 0;
VehicleInfo[theunimpoundid][vImpounded] = 0;
VehicleInfo[theunimpoundid][vImpoundFee] = 0;
myStrcpy(VehicleInfo[theunimpoundid][vImpoundReason], "None");
ReloadVehicle(theunimpoundid);
printf("%d", theunimpoundid);
return 1;
}

new iBigStr[1575], iCount, iSmllStr[128];
strcat(iBigStr, "Vehicle\tImpound fee\tImpound Reason\n");

VehicleLoop(v)
{
if (VehicleInfo[v][vActive] != true) continue;
if (strcmp(PlayerName(playerid), VehicleInfo[v][vOwner], false)) continue;
if (VehicleInfo[v][vImpounded] != 1) continue;
if (VehicleInfo[v][vImpounded] == 1 && VehicleInfo[v][vSpawned] != true)
{
iCount++;
format(iSmllStr, sizeof(iSmllStr), "%d %s(%d)\t%d\t%s\n", v, GetVehicleNameFromModel(VehicleInfo[v][vModel]), VehicleInfo[v][rID], VehicleInfo[v][vImpoundFee], VehicleInfo[v][vImpoundReason]);
}
strcat(iBigStr, iSmllStr);
ShowPlayerDialog(playerid, DIALOG_UNIMPOUND, DIALOG_STYLE_TABLIST_HEADERS, "{3196ef}Please select vehicle you would like to unimpound", iBigStr, "Select", "Exit");
}

if (!iCount) SendClientError(playerid, "You don't have any impounded vehicle");
return 1;
}

LazzyBoy
31/10/2017, 02:43 PM
Yes actually , and thanks i've tested the above codes and it does works perfectly, i thought that it was required an ELSE in order to make it work perfectly so , Thanks alot mate.