SA-MP Forums Archive
Command outputs "SERVER : Unknown Command" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command outputs "SERVER : Unknown Command" (/showthread.php?tid=484176)



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(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!


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(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;




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(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


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