CMD:taxitest(playerid, params[]) { Taxi_ShowCalls(playerid); return 1; }
stock Taxi_ShowCalls(playerid) { static string[2048]; string[0] = 0; foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) { format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i)); } if (!strlen(string)) { SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept."); } else SendClientMessage(playerid, COLOR_LIGHTRED, string); return 1; }
foreach (new i : Player) { if(GetPVarInt(i, "TaxiRequest") == 1) //change 1 to whatever you're using in this PVar { format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i)); SendClientMessage(playerid, COLOR_LIGHTRED, string); } }
Код:
CMD:taxitest(playerid, params[]) { Taxi_ShowCalls(playerid); return 1; } Код:
stock Taxi_ShowCalls(playerid) { static string[2048]; string[0] = 0; foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) { format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i)); } if (!strlen(string)) { SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept."); } else SendClientMessage(playerid, COLOR_LIGHTRED, string); return 1; } |
static
string[2048]; that's a lot, don't you think? and why did you do static? just do new string[200]; is fair enough. |
Is that the only ZCMD command you're using? I doubt this would solve it but I remember having the same issue and I had to switch from using CMD: to COMMAND:, give it a shot.
|
Yes, that is very large and should be made smaller. Yes it is static and it CAN BE STATIC. It's static to that function, so it makes sense if you know what it means. Plus you're already trying to clear it ("[0] = 0") so it's fine.
"COMMAND" and "CMD" are synonymous in ZCMD. In fact, they are just both just predefined macros to the same shit. So no that's not the problem. @OP: Put some 'print's all over (EVERYWHERE). See where they get printed and where they don't. |
stock Taxi_ShowCalls(playerid) { static string[2048]; string[0] = 0; foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) print("1"); { format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i)); // this line gets an error } if (!strlen(string)) { SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept."); } else SendClientMessage(playerid, COLOR_LIGHTRED, string); return 1; }
Line(8459) : error 017: undefined symbol "i"
stock Taxi_ShowCalls(playerid)
{
static
string[2048];
string[0] = 0;
printf("string = %s", string);
foreach (new i : Player) {
if (GetPVarInt(i, "TaxiRequest"))
{
format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i));
print("appending");
}
}
if (!strlen(string))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept.");
print("if")
}
else SendClientMessage(playerid, COLOR_LIGHTRED, string), print("else");
print("end");
return 1;
}
Yes, that is very large and should be made smaller. Yes it is static and it CAN BE STATIC. It's static to that function, so it makes sense if you know what it means. Plus you're already trying to clear it ("[0] = 0") so it's fine.
"COMMAND" and "CMD" are synonymous in ZCMD. In fact, they are just both just predefined macros to the same shit. So no that's not the problem. @OP: Put some 'print's all over (EVERYWHERE). See where they get printed and where they don't. |