Server:Unknown command
#1

I have commands in my script but when i type them it says Server:Unknown Command.Why ?
Here is the last command with return:
Код:
if(strcmp(cmd, "/v", true) == 0)
    {
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp) || strlen(tmp) > 32) { return SendClientMessage(playerid, COLOR, ""RED"Usage:/v [ID/NAME]"); }
        new car;
        if(!IsNumeric(tmp)) { car = GetVehicleModelIDFromName(tmp); } else { car = strval(tmp); }
        if(car > 611 || car < 400) { return SendClientMessage(playerid, COLOR, ""RED"Invalid Vehicle/Name!"); }
        if(CreateCar[playerid] != -1) { DestroyVehicle(CreateCar[playerid]); }
        new Float:pos[4];
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        GetPlayerFacingAngle(playerid, pos[3]);
        CreateCar[playerid] = CreateVehicle(car, pos[0], pos[1], pos[2], pos[3], -1, -1, 50000);
        PutPlayerInVehicle(playerid, CreateCar[playerid], 0);
        SetCameraBehindPlayer(playerid);
        new MaxPlayers = GetMaxPlayers();
        for(new i; i < MaxPlayers; i++)
        {
            if(!IsPlayerConnected(i) || i == playerid) continue;
            SetVehicleParamsForPlayer(CreateCar[playerid], i, 0, true);
        }
        return 1;
	}
    return SendClientMessage(playerid, COLOR, ""RED"Type /help to see the commands!");
}
Reply
#2

Show the code before this command, the error is propably in this section.
Reply
#3

Here is the command:
Код:
if(strcmp(cmd, "/givecash", true) == 0)
    {
        new reciever, money;
        if (sscanf(cmdtext, "dd", reciever, money)) SendClientMessage(playerid, COLOR, ""RED"Usage: /givecash [playerid] [amount]");
        else
        {
            if(GetPlayerMoney(playerid) < money)
            {
                SendClientMessage(playerid, COLOR, ""RED"You don't have that much!");
                return 1;
            }
            new string[64], playername[MAX_PLAYER_NAME], playername2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername, sizeof(playername));
            GetPlayerName(reciever, playername2, sizeof(playername2));
            format(string, sizeof(string), ""GREEN"You recieved &%d from %s.", money, playername);
            SendClientMessage(playerid, COLOR, string);
            format(string, sizeof(string), ""GREEN"You gave &%d to %s.", money, playername);
            SendClientMessage(playerid, COLOR, string);
            GivePlayerMoney(playerid, GetPlayerMoney(playerid) - money);
            GivePlayerMoney(reciever, GetPlayerMoney(reciever) + money);
            return 1;
        }
    }
I have two commands with zcmd and the other are strcmp.Is this the problem?
Reply
#4

Quote:
Originally Posted by IvancheBG
Посмотреть сообщение
Here is the command:
I have two commands with zcmd and the other are strcmp.Is this the problem?
as far as i know yes.
either convert all to zcmd, or to strcmp or
https://sampforum.blast.hk/showthread.php?tid=276063 try this
Reply
#5

How to convert them in strcmp?
Reply
#6

if u use zcmd + strcmp all strcmp commands will not work.Only ZCMD one's will work.IDK y?
Reply
#7

As you can't use ZCMD + strcmp together, convert all to ZCMD

Just a small off-topic addition: I see you are using color embeddings like this

"RED" - I suppose you have defined them as "#define RED FFFFFF (whatever red is)". In that case you should not use "RED" but "#RED"
Reply
#8

Thanks but how to convert them in zcmd.
Reply
#9

Okay i tried to convert my cancel,dm1 and dm2 command in zcmd but i have errors:
Here are the commands:
Код:
//------------------------------CancelCommand-----------------------------//
CMD:cancel(playerid, params[])
{
    if(isindm2[playerid]==1)
    isindm2[playerid] = 0;
    if(isindm1[playerid]==1)
    isindm1[playerid] = 0;
    else return SendClientMessage(playerid, COLOR, ""RED"You're not in a Dm!");
    SetPlayerPos(playerid, 0.0 ,0.0, 3.0);
    new string[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof(string)," "GREEN"%s "RED"exit DM1",pName);
    SendClientMessageToAll(COLOR_YELLOW,string);
    return 1;
}

if(isindm1[playerid]==1) return SendClientMessage(playerid, COLOR, ""RED"You need to exit the deathmatch first.");
if(isindm2[playerid]==1) return SendClientMessage(playerid, COLOR, ""RED"You need to exit the deathmatch first.");
//-------------------------------Dm1Command-------------------------------//
CMD:dm1(playerid, params[])
{
    isindm1[playerid]=1;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, 1776.9133, -1801.5455, 52.4688);
    SetPlayerFacingAngle(playerid, 0);
    SetPlayerVirtualWorld(playerid, 1);
    new string[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof(string)," "GREEN"%s "RED"Joined Dm1",pName);
    SendClientMessageToAll(COLOR_YELLOW,string);
    SendClientMessage(playerid,COLOR_SEAGREEN,"Type /cancel To Leave Dm1!");
    return 1;
}
//-------------------------------Dm2Command-------------------------------//
CMD:dm2(playerid, params[])
{
    isindm2[playerid]=1;
    new rand = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    new string[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof(string)," "GREEN"%s "RED"Joined Dm2",pName);
    SendClientMessageToAll(COLOR,string);
    SendClientMessage(playerid,COLOR_SEAGREEN,"Type /cancel To Leave Dm2!");
    return 1;
}
And the errors:
Код:
C:\Documents and Settings\user\Desktop\server samp\gamemodes\testserver.pwn(2054) : error 010: invalid function or declaration
C:\Documents and Settings\user\Desktop\server samp\gamemodes\testserver.pwn(2055) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#10

Yeah, these two lines (2054 and 2055) are invalid. Why did you place them there after all? Remove them.

And again

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Just a small off-topic addition: I see you are using color embeddings like this

"RED" - I suppose you have defined them as "#define RED FFFFFF (whatever red is)". In that case you should not use "RED" but "#RED"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)