13.07.2009, 15:25
Ok, my problem is that all variables like "biz" and "row" created in the /bizinfocommand(i show you the command bellow) will have the same effect as a global OnPlayerCommandText variable...
If I want to create a variable with the same name but at a different level for example if I put this under my /bizinfo command:
if (strcmp(cmd, "/test", true) == 0)
{
new biz = 0;
return 1;
}
it will say:
error 021: symbol already defined: "biz"
warning 219: local variable "biz" shadows a variable at a preceding level
The /bizinfo command
http://pastebin.com/m9d98f77
One of the part of the script where I get error 021 + warning 139:
http://pastebin.com/m104282d8
There, the line "new biz = PlayerInfo[playerid][pBiz];" will create error 021 and warning 139
Seriously this piss me off because i see no reason why this happens...
Here is my problem:
This causes no errors
But this:
causes 1 error, the line "new zone[25];" under /findcar1 causes error 021: symbol already defined: "zone"
WHY? What's wrong with the comment part?!
This pisses me off I trying to fix it for days!
I know I could just take another name but this is not clear, this error is not normal and I want to know WHY it is here.
NOTE: Ignore all messages on the first page, read since this post: http://forum.sa-mp.com/index.php?top...1913#msg731913
If I want to create a variable with the same name but at a different level for example if I put this under my /bizinfo command:
if (strcmp(cmd, "/test", true) == 0)
{
new biz = 0;
return 1;
}
it will say:
error 021: symbol already defined: "biz"
warning 219: local variable "biz" shadows a variable at a preceding level
The /bizinfo command
http://pastebin.com/m9d98f77
One of the part of the script where I get error 021 + warning 139:
http://pastebin.com/m104282d8
There, the line "new biz = PlayerInfo[playerid][pBiz];" will create error 021 and warning 139
Seriously this piss me off because i see no reason why this happens...
Here is my problem:
This causes no errors
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new string[256];
new idx = 0;
cmd = strtok(cmdtext, idx);
new sendername[MAX_PLAYER_NAME];
new target[MAX_PLAYER_NAME];
new targetid;
new i;
if(!strcmp(cmdtext, "/carlist"))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCar] == -1 && PlayerInfo[playerid][pCar2] == -1 && PlayerInfo[playerid][pCar3] == -1 && PlayerInfo[playerid][pCar4] == -1 && PlayerInfo[playerid][pCar5] == -1)
{
SendClientMessage(playerid, RED, "Vous ne possйdez aucun vйhicule.");
return 1;
}
new desc[MAX_PLAYER_NAME*4], zone[24];
new spawnedveh = 0;
if(PlayerInfo[playerid][pCar] != -1)
{
/*new sql[150], Fields[25][40];
format(sql, sizeof(sql), "SELECT * FROM cars2 WHERE id=%d", PlayerInfo[playerid][pCar]);
mysql_query(sql);
mysql_store_result();
mysql_fetch_row(tmp);
split(tmp, Fields, '|');
mysql_free_result();
memcpy(desc, Fields[9], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
for(i = 0; i < sizeof(gSAZones); i++ )
{
if(floatstr(Fields[2]) >= gSAZones[i][SAZONE_AREA][0] && floatstr(Fields[2]) <= gSAZones[i][SAZONE_AREA][3] && floatstr(Fields[3]) >= gSAZones[i][SAZONE_AREA][1] && floatstr(Fields[3]) <= gSAZones[i][SAZONE_AREA][4])
{
format(zone, sizeof(zone), gSAZones[i][SAZONE_NAME]);
break;
}
format(zone, sizeof(zone), "Inconnue");
}
format(string, sizeof(string), "[1] Modиle: %s, Niveau de l'alarme: %d, Zone: %s", GetVehicleName(strval(Fields[1])),strval(Fields[14]), zone);*/
for(i = 0; i<MAX_VEHICLES;i++)
{
if(TmpCarID[i] == PlayerInfo[playerid][pCar] && TmpCarKeys[playerid] == i || TmpCarKeys2[playerid] == i)
spawnedveh++;
break;
}
if(spawnedveh == 1) SendClientMessage(playerid, GREEN, string);
else SendClientMessage(playerid, WHITE, string);
}
}
return 1;
}
if(!strcmp(cmdtext, "/findcar1"))
{
if(IsPlayerConnected(playerid))
{
if(TmpCarKeys[playerid] == -1)
{
SendClientMessage(playerid, RED, "Vous n'avez aucun vйhicule spawned.");
return 1;
}
new driving = 0;
for(i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsPlayerInAnyVehicle(i)) continue;
if(GetPlayerVehicleID(i) == TmpCarKeys[playerid]) { driving = 1; break; }
}
}
new zone[25];
GetVehicleZone(TmpCarKeys[playerid], zone);
if(driving == 1) format(string, sizeof(string), "Votre %s se dйplace, il se trouve en ce moment dans %s", GetVehicleName(TmpCarKeys[playerid]), zone);
else
{
format(string, sizeof(string), "Votre %s se trouve dans %s", GetVehicleName(TmpCarKeys[playerid]), zone);
new Float:x, Float:y, Float:z;
GetVehiclePos(TmpCarKeys[playerid], x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 5);
}
SendClientMessage(playerid, YELLOW2, string);
}
return 1;
}
return 0;
}
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new tmp[256];
new string[256];
new idx = 0;
cmd = strtok(cmdtext, idx);
new sendername[MAX_PLAYER_NAME];
new target[MAX_PLAYER_NAME];
new targetid;
new i;
if(!strcmp(cmdtext, "/carlist"))
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pCar] == -1 && PlayerInfo[playerid][pCar2] == -1 && PlayerInfo[playerid][pCar3] == -1 && PlayerInfo[playerid][pCar4] == -1 && PlayerInfo[playerid][pCar5] == -1)
{
SendClientMessage(playerid, RED, "Vous ne possйdez aucun vйhicule.");
return 1;
}
new desc[MAX_PLAYER_NAME*4], zone[24];
new spawnedveh = 0;
if(PlayerInfo[playerid][pCar] != -1)
{
new sql[150], Fields[25][40];
format(sql, sizeof(sql), "SELECT * FROM cars2 WHERE id=%d", PlayerInfo[playerid][pCar]);
mysql_query(sql);
mysql_store_result();
mysql_fetch_row(tmp);
split(tmp, Fields, '|');
mysql_free_result();
memcpy(desc, Fields[9], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4);
for(i = 0; i < sizeof(gSAZones); i++ )
{
if(floatstr(Fields[2]) >= gSAZones[i][SAZONE_AREA][0] && floatstr(Fields[2]) <= gSAZones[i][SAZONE_AREA][3] && floatstr(Fields[3]) >= gSAZones[i][SAZONE_AREA][1] && floatstr(Fields[3]) <= gSAZones[i][SAZONE_AREA][4])
{
format(zone, sizeof(zone), gSAZones[i][SAZONE_NAME]);
break;
}
format(zone, sizeof(zone), "Inconnue");
}
format(string, sizeof(string), "[1] Modиle: %s, Niveau de l'alarme: %d, Zone: %s", GetVehicleName(strval(Fields[1])),strval(Fields[14]), zone);
for(i = 0; i<MAX_VEHICLES;i++)
{
if(TmpCarID[i] == PlayerInfo[playerid][pCar] && TmpCarKeys[playerid] == i || TmpCarKeys2[playerid] == i)
spawnedveh++;
break;
}
if(spawnedveh == 1) SendClientMessage(playerid, GREEN, string);
else SendClientMessage(playerid, WHITE, string);
}
}
return 1;
}
if(!strcmp(cmdtext, "/findcar1"))
{
if(IsPlayerConnected(playerid))
{
if(TmpCarKeys[playerid] == -1)
{
SendClientMessage(playerid, RED, "Vous n'avez aucun vйhicule spawned.");
return 1;
}
new driving = 0;
for(i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsPlayerInAnyVehicle(i)) continue;
if(GetPlayerVehicleID(i) == TmpCarKeys[playerid]) { driving = 1; break; }
}
}
new zone[25];
GetVehicleZone(TmpCarKeys[playerid], zone);
if(driving == 1) format(string, sizeof(string), "Votre %s se dйplace, il se trouve en ce moment dans %s", GetVehicleName(TmpCarKeys[playerid]), zone);
else
{
format(string, sizeof(string), "Votre %s se trouve dans %s", GetVehicleName(TmpCarKeys[playerid]), zone);
new Float:x, Float:y, Float:z;
GetVehiclePos(TmpCarKeys[playerid], x, y, z);
SetPlayerCheckpoint(playerid, x, y, z, 5);
}
SendClientMessage(playerid, YELLOW2, string);
}
return 1;
}
return 0;
}
WHY? What's wrong with the comment part?!
This pisses me off I trying to fix it for days!
I know I could just take another name but this is not clear, this error is not normal and I want to know WHY it is here.
NOTE: Ignore all messages on the first page, read since this post: http://forum.sa-mp.com/index.php?top...1913#msg731913