PROBLEM STRING! NEED HELP!
#1

hello SA-MP Forums. i have string problem in OnPlayerCommandText. And i show you code:

Код HTML:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/Iaragebi", cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Iaragebi", "Desert Eagle\nAK-47\nCombat Shotgun", "Archeva", "Gamosvla");
		return 1;
	}
	if(strcmp(cmdtext, "/setskin", true) == 0) {
		new idx;
        if(IsPlayerConnected(playerid)) {
            // Change !IsPlayerAdmin(playerid) --> Rcon Administrator to your Admin Variable.
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Shen Ar Shegidzlia Gamoiyeno Es Commandi!");
            /*
            if(Admin_Variable[playerid][Admin_enum] < your_level) return SendClientMessage(playerid, -1, "You cannot use this command!");
            */
            new
                tmp[256],
                tmp2[256],
                id = strval(tmp),
                skin = strval(tmp2);
            tmp = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);
            if(!strlen(tmp)) {
                SendClientMessage(playerid, -1, "Gamoyeneba: /setskin [ID] [Skin ID]");
                return 1;
            }
            if(!strlen(tmp2)) {
                SendClientMessage(playerid, -1, "Gamoyeneba: /setskin [ID] [Skin ID]");
                return 1;
            }
            SetPlayerSkin(id, skin);
        }
        return 1;
    }
	if(strcmp(cmdtext, "/veh", true) == 0) {
    {
    	new string[128];
        new CreatedCars[100];
        new CreatedCar;
        new idx;
        new tmp[128];
        new cmd[256];
        cmd = strtok(cmdtext, idx);
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "Gamoyeneba: /veh [carid] [color1] [color2]");
                return 1;
            }
            new car;
            car = strval(tmp);
            if(car < 400 || car > 611) { SendClientMessage(playerid, 0x4B00B0AA, "   Manqanis ID-ebi aris Mxolod 400-ze Meti Da 611'ze Naklebi!"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "Gamoyeneba: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color1;
            color1 = strval(tmp);
            if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, 0x4B00B0AA, "   Feris ID-ebi aris mxolod  0-Is Zevit Da 126-is Qvevit!"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "Gamoyeneba: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color2;
            color2 = strval(tmp);
            if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, 0x4B00B0AA, "   Feris ID-ebi aris mxolod  0-Is Zevit Da 126-is Qvevit!"); return 1; }
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X,Y,Z);
            new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
            CreatedCars[CreatedCar] = carid;
            CreatedCar ++;
            format(string, sizeof(string), "   Manqana %d Chamovarda.", carid);
            SendClientMessage(playerid, 0x4B00B0AA, string);
        }
        return 1;
    }
    return 0;
}
error is in only command /veh.

so now is show you errors:
Код HTML:
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(392) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(394) : warning 217: loose indentation
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(394) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(394) : error 004: function "S@@_OnPlayerEnterVehicle" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(399) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(399) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(399) : error 004: function "S@@_OnPlayerExitVehicle" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(404) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(404) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(404) : error 004: function "S@@_OnPlayerStateChange" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(409) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(409) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(409) : error 004: function "S@@_OnPlayerEnterCheckpoint" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(414) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(414) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(414) : error 004: function "S@@_OnPlayerLeaveCheckpoint" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(419) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(419) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(419) : error 004: function "S@@_OnPlayerEnterRaceCheckpoint" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(424) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(424) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(424) : error 004: function "S@@_OnPlayerLeaveRaceCheckpoint" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(429) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(429) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(429) : error 004: function "S@@_OnRconCommand" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(434) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(434) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(434) : error 004: function "S@@_OnPlayerRequestSpawn" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(439) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(439) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(439) : error 004: function "S@@_OnObjectMoved" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(444) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(444) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(444) : error 004: function "S@@_OnPlayerObjectMoved" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(449) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(449) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(449) : error 004: function "S@@_OnPlayerPickUpPickup" is not implemented
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(454) : warning 225: unreachable code
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(454) : error 029: invalid expression, assumed zero
D:\Files\Programs\BIG CITY LIFE\gamemodes\BCL.pwn(454) : error 004: function "S@@_OnVehicleMod" is not implemented

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
PLEASE HELP ME! Thanks in advance.
Reply
#2

It gives you errors, because you have double {{
pawn Код:
if(strcmp(cmdtext, "/veh", true) == 0) {
    {
See?
Replace with
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Iaragebi", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Iaragebi", "Desert Eagle\nAK-47\nCombat Shotgun", "Archeva", "Gamosvla");
        return 1;
    }
    if(strcmp(cmdtext, "/setskin", true) == 0) {
        new idx;
        if(IsPlayerConnected(playerid)) {
            // Change !IsPlayerAdmin(playerid) --> Rcon Administrator to your Admin Variable.
            if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Shen Ar Shegidzlia Gamoiyeno Es Commandi!");
            /*
            if(Admin_Variable[playerid][Admin_enum] < your_level) return SendClientMessage(playerid, -1, "You cannot use this command!");
            */

            new
                tmp[256],
                tmp2[256],
                id = strval(tmp),
                skin = strval(tmp2);
            tmp = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);
            if(!strlen(tmp)) {
                SendClientMessage(playerid, -1, "Gamoyeneba: /setskin [ID] [Skin ID]");
                return 1;
            }
            if(!strlen(tmp2)) {
                SendClientMessage(playerid, -1, "Gamoyeneba: /setskin [ID] [Skin ID]");
                return 1;
            }
            SetPlayerSkin(id, skin);
        }
        return 1;
    }
    if(strcmp(cmdtext, "/veh", true) == 0)
    {
        new CreatedCars[100];
        new CreatedCar;
        new idx;
        new tmp[128];
        new cmd[256];
        cmd = strtok(cmdtext, idx);
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "Gamoyeneba: /veh [carid] [color1] [color2]");
                return 1;
            }
            new car;
            car = strval(tmp);
            if(car < 400 || car > 611) { SendClientMessage(playerid, 0x4B00B0AA, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color1;
            color1 = strval(tmp);
            if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, 0x4B00B0AA, "   Color Number can't be below 0 or above 126 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, 0x4B00B0AA, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color2;
            color2 = strval(tmp);
            if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, 0x4B00B0AA, "   Color Number can't be below 0 or above 126 !"); return 1; }
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X,Y,Z);
            new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
            CreatedCars[CreatedCar] = carid;
            CreatedCar ++;
            new string[64]; // <--
            format(string, sizeof(string), "   Vehicle %d spawned.", carid);
            SendClientMessage(playerid, 0x4B00B0AA, string);
        }
        return 1;
    }
    return 0;
}
Reply
#3

Thanks it's fixed but in game when i type /veh server says: UNKNOW COMMAND. please if you have this command, give me !
Reply
#4

In my opinion, strcmp is not for commands. You can start with ZCMD which is faster and it saves you time from making a command. It's compatitive with sscanf and it's really fast.

[INC] zcmd 0.3.1 | Fast & Simple Command Processor (updated 30/10/2009)
[TUTORIAL]How to create commands with ZCMD & sscanf

If you need anything, just post here or PM me and I'll help you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)