SA-MP Forums Archive
how to convert into zcmd - 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: how to convert into zcmd (/showthread.php?tid=302173)



how to convert into zcmd - Danyal - 07.12.2011

pawn Код:
if(!strcmp(cmd, "/colocar", true))
        {
                if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "*You must be in a vehicle.");
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GREY, "Use: /place [light-neon] [color]");
                    SendClientMessage(playerid, COLOR_GREY, "Light color: blue - green - white - red - random.");
                    SendClientMessage(playerid, COLOR_GREY, "Neon colors: yellow - pink - blue - green - white - red - random.");
                    return 1;
                }
                if(!strcmp(tmp, "light", true))
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Use: /place [light-neon] [color]");
                        SendClientMessage(playerid, COLOR_GREY, "Light color: blue - green - white - red - random.");
                        SendClientMessage(playerid, COLOR_GREY, "Neon colors: yellow - pink - blue - green - white - red - random.");
                        return 1;
                    }
                    if(Neon[GetPlayerVehicleID(playerid)][TieneLuz] != 0) return SendClientMessage(playerid, COLOR_GREY, "* Este vehнculo ya tiene un neуn colocado.");
                    if(Neon[GetPlayerVehicleID(playerid)][LightsHas] != 0) return SendClientMessage(playerid, COLOR_GREY, "*This vehicle has already placed a neon.");
                    if(!strcmp(tmp, "blue", true))
                    {
                        format(message, sizeof(message), "*You put a light color %s in the car .", tmp);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                        return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 1;
                    }
                    if(!strcmp(tmp, "green", true))
                    {
                        Neon[GetPlayerVehicleID(playerid)][LightsHas] = 2;
                        format(message, sizeof(message), "*You put a light color %s in the car .", tmp);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                        return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 2;
                    }
                    if(!strcmp(tmp, "white", true))
                    {
                        format(message, sizeof(message), "*You put a light color %s in the car .", tmp);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                        return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 3;
                    }
                    if(!strcmp(tmp, "red", true))
                    {
                        format(message, sizeof(message), "*You put a light color %s in the car .", tmp);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                        return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 4;
                    }
                    if(!strcmp(tmp, "random", true))
                    {
                        format(message, sizeof(message), "*You put a light color %s in the car .", tmp);
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                        new color = random(7);
                        if(color > 8) color = random(7);
                        Neon[GetPlayerVehicleID(playerid)][LightsHas] = color;
                        return 1;
                    }
                    return 1;
                }
                if(!strcmp(tmp, "neon", true))
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Use: /place [light-neon] [color]");
                        SendClientMessage(playerid, COLOR_GREY, "Light color: blue - green - white - red - random.");
                        SendClientMessage(playerid, COLOR_GREY, "Neon colors: yellow - pink - blue - green - white - red - random.");
                        return 1;
                    }
            if(Neon[GetPlayerVehicleID(playerid)][ColorNeon] != 0) return SendClientMessage(playerid, COLOR_GREY, "*This vehicle has already placed a neon.");
            if(!strcmp(tmp, "blue", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 1;
            }
            if(!strcmp(tmp, "green", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 2;
            }
            if(!strcmp(tmp, "white", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 3;
            }
            if(!strcmp(tmp, "yellow", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 4;
            }
            if(!strcmp(tmp, "red", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 5;
            }
            if(!strcmp(tmp, "pink", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                return Neon[GetPlayerVehicleID(playerid)][ColorNeon] = 6;
            }
            if(!strcmp(tmp, "random", true))
            {
                format(message, sizeof(message), "*You put a neon color %s in the car.", tmp);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
                new color = random(7);
                if(color > 8) color = random(7);
                Neon[GetPlayerVehicleID(playerid)][ColorNeon] = color;
                return 1;
            }
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "Use: /place [light-neon] [color]");
            SendClientMessage(playerid, COLOR_GREY, "Light color: blue - green - white - red - random.");
            SendClientMessage(playerid, COLOR_GREY, "Neon colors: yellow - pink - blue - green - white - red - random.");
        }
        return 1;
    }
how to convert above command into zcmd

pawn Код:
CMD:neons(playerid, params[])
CMD:lights(playerid, params[])
above are my commands /neons and /lights command

EDIT:
pawn Код:
new cmd[256], idx, tmp[256];
cmd = strtok(cmdtext, idx);
i forgot these undefined symbols


Re: how to convert into zcmd - WLSF - 07.12.2011

pawn Код:
CMD:neons(playerid, params[])
{
    new wii[128];
    if(sscanf(params,"s[128]", wii)) return false;
    if(Neon[GetPlayerVehicleID(playerid)][LightsHas] != 0) return false;
    ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "wii_Neons", "Blue\r\nGreen\r\nWhite","Change","Cancel");
    return true;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == dialogid)
    {
        if(listitem == 0) return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 1;
        if(listitem == 1) return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 2;
        if(listitem == 2) return Neon[GetPlayerVehicleID(playerid)][LightsHas] = 3;
        return true;
    }
    return 1;
}
Some example...


Re: how to convert into zcmd - English-Conceptz - 07.12.2011

or could use ZCMD & sscanf ?

first few lines:

PHP код:
CMD:colocarplayeridparams[ ] )
        {
                if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_GREY"*You must be in a vehicle.");
                new 
lightColor,neonColor;
                if ( 
sscanfparams"ss"lightColor,neonColor ) ) return SendClientMessageplayeridCOLOR_RED"Usage: /place [light-neon] [color]" );
                
SendClientMessage(playeridCOLOR_GREY"Light color: blue - green - white - red - random.");
                
SendClientMessage(playeridCOLOR_GREY"Neon colors: yellow - pink - blue - green - white - red - random.");

see where "ss" is on the 5th line of my code if u didnt no what the letters are:

c - A character.
d, i - An integer.
h, x - A hex number (e.g. a colour).
f - A float.
s - A string.
z - An optional string.
pX - An additional delimiter where X is another character.
'' - Encloses a litteral string to locate.
u - User, takes a name, part of a name or an id and returns the id if they're connected.

you just put the letter which refers to the variable your storing the response in if theres two variables 1,2 then u need two letter in the "" if theres 4 variables 1,2,3,4 then you would need 4 letters "iiii"