Command outputs "SERVER : Unknown Command"
#1

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(playeridparams[])
{
    
SendClientMessage(playerid, -1"{F0354E}----------------------------");
    for(new 
1sizeof(VehicleInfo); i++)
    {
        new 
string[258];
        if(!
strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false))
        {
            
format(stringsizeof(string), "- %s (ID : %d)"GetVehicleName(i), i);
            
SendClientMessage(playerid, -1string);
        }
        else
        {
            
SendClientMessage(playerid, -1"You don't own any vehicles!");
        }
    }
    return 
1;

Thanks!
Reply
#2

I bealive you can't use strcmp in ZCMD.
Reply
#3

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.
Reply
#4

Weird, works just fine for me:


Changed to print out "hello" in your format as I didn't have the same enums obviously.
Reply
#5

Quote:
Originally Posted by MatriXgaMer
Посмотреть сообщение
I bealive you can't use strcmp in ZCMD.
Reply
#6

Quote:
Originally Posted by yoran765
Посмотреть сообщение
PHP код:
COMMAND:myvehiclelist(playeridparams[])
{
    for(new 
1sizeof(VehicleInfo); i++)
    {
        new 
string[258];
        if(!
strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false))
        {
            
format(stringsizeof(string), "- %s (ID : %d)"GetVehicleName(i), i);
            
SendClientMessage(playerid, -1string);
        }
        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(playeridparams[])
{
    
SendClientMessage(playerid, -1"{F0354E}----------------------------");
    new 
string[95],tmpS[26];
    for(new 
1sizeof(VehicleInfo); i++)
    {
        if(
strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false)) continue;
        
format(tmpSsizeof 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;

Reply
#7

Check if you don't have any other commands with the same name. :S

EDIT: Didn't see someone posting before me sorry. :P
Reply
#8

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(playeridparams[])
{
    
SendClientMessage(playerid, -1"{F0354E}----------------------------");
    new 
string[95],tmpS[26];
    for(new 
1sizeof(VehicleInfo); i++)
    {
        if(
strcmp(VehicleInfo[i][vOwner], PlayerName(playerid), false)) continue;
        
format(tmpSsizeof 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
Reply
#9

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... ?
Reply
#10

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)" ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)