Command outputs "SERVER : Unknown Command" -
yoran765 - 29.12.2013
Hi,
I've scripted a /myvehiclelist command and everything works fine. But it outputs "Server : Unknown Command" aswell! Not sure how to fix it any help?
Photo :
Script :
PHP код:
COMMAND:myvehiclelist(playerid, params[])
{
SendClientMessage(playerid, -1, "{F0354E}----------------------------");
for(new i = 1; i < sizeof(VehicleInfo); i++)
{
new string[258];
if(!strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false))
{
format(string, sizeof(string), "- %s (ID : %d)", GetVehicleName(i), i);
SendClientMessage(playerid, -1, string);
}
else
{
SendClientMessage(playerid, -1, "You don't own any vehicles!");
}
}
return 1;
}
Thanks!
Re: Command outputs "SERVER : Unknown Command" -
MatriXgaMer - 29.12.2013
I bealive you can't use
strcmp in ZCMD.
Re: Command outputs "SERVER : Unknown Command" -
PrivatioBoni - 29.12.2013
Quote:
Originally Posted by MatriXgaMer
I bealive you can't use strcmp in ZCMD.
|
I'm pretty sure you can. It's just string compare. Anyway, not really sure what your problem is, but I don't think it's that.
Re: Command outputs "SERVER : Unknown Command" -
Hansrutger - 29.12.2013
Weird, works just fine for me:
Changed to print out "hello" in your format as I didn't have the same enums obviously.
Re: Command outputs "SERVER : Unknown Command" -
[WA]iRonan - 29.12.2013
Quote:
Originally Posted by MatriXgaMer
I bealive you can't use strcmp in ZCMD.
|
AW: Command outputs "SERVER : Unknown Command" -
CutX - 29.12.2013
Quote:
Originally Posted by yoran765
PHP код:
COMMAND:myvehiclelist(playerid, params[])
{
for(new i = 1; i < sizeof(VehicleInfo); i++)
{
new string[258];
if(!strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false))
{
format(string, sizeof(string), "- %s (ID : %d)", GetVehicleName(i), i);
SendClientMessage(playerid, -1, string);
}
else
{
SendClientMessage(playerid, -1, "You don't own any vehicles!");
}
}
return 1;
}
|
never use SendClientMessage in a loop.
use strcat instead.
You're also
creating a HUGE string every loop-time -> not good if that thing runs about 500 times.
This can even cause to command to "quit", which obviously happened here.
try this:
PHP код:
COMMAND:myvehiclelist(playerid, params[])
{
SendClientMessage(playerid, -1, "{F0354E}----------------------------");
new string[95],tmpS[26];
for(new i = 1; i < sizeof(VehicleInfo); i++)
{
if(strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false)) continue;
format(tmpS, sizeof tmpS, "- %s (ID : %d)\n", GetVehicleName(i), i);
strcat(string,tmpS);
}
if(string[0] == EOS) return SendClientMessage(playerid, -1, "You don't own any vehicles!");
ShowPlayerDialog(playerid,9999,DIALOG_STYLE_MSGBOX,"My Vehicles",string,"Okey","");//just guessin' some id
return 1;
}
Re: Command outputs "SERVER : Unknown Command" -
Hansrutger - 29.12.2013
Check if you don't have any other commands with the same name. :S
EDIT: Didn't see someone posting before me sorry. :P
Re: AW: Command outputs "SERVER : Unknown Command" -
yoran765 - 29.12.2013
Quote:
Originally Posted by CutX
never use SendClientMessage in a loop.
use strcat instead.
You're also creating a HUGE string every loop-time -> not good if that thing runs about 500 times.
This can even cause to command to "quit", which obviously happened here.
try this:
PHP код:
COMMAND:myvehiclelist(playerid, params[])
{
SendClientMessage(playerid, -1, "{F0354E}----------------------------");
new string[95],tmpS[26];
for(new i = 1; i < sizeof(VehicleInfo); i++)
{
if(strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false)) continue;
format(tmpS, sizeof tmpS, "- %s (ID : %d)\n", GetVehicleName(i), i);
strcat(string,tmpS);
}
if(string[0] == EOS) return SendClientMessage(playerid, -1, "You don't own any vehicles!");
ShowPlayerDialog(playerid,9999,DIALOG_STYLE_MSGBOX,"My Vehicles",string,"Okey","");//just guessin' some id
return 1;
}
|
Still outputs "Server : Unknown command"
Doesn't show the dialog aswell
AW: Command outputs "SERVER : Unknown Command" -
CutX - 29.12.2013
im not sure but, don't you also need something like
PHP код:
#pragma unused params
cuz were not using params here.
not sure but maybe... ?
Re: Command outputs "SERVER : Unknown Command" -
yoran765 - 09.01.2014
Quote:
Originally Posted by Hansrutger
Weird, works just fine for me:
Changed to print out "hello" in your format as I didn't have the same enums obviously.
|
Pretty late reaction but could you show me the string you used for "GetVehicleName(i)" ?