sscanf to strcmp
#1

pawn Код:
CMD:givegun(playerid, params[])
{
    new id, slot, wepid, ammo, wepname[128];
    if(!CheckAdmin(playerid, ADMIN_LEVEL_5)) return NotAuthMSG(playerid);
    if(sscanf(params,"uddd", id, slot, wepid, ammo)) return SyntaxMSG(playerid, "/givegun [playerid] [WepSlot (1-Melee,2-Primary,3-Secondary)] [WepID] [Ammo]");
    if(!PlayerIsOn(id)) return NotConnectedMSG(playerid);

    if(wepid >= 35 && wepid <= 40 || wepid >= 42 && wepid <= 46) return SendClientMessage(playerid, -1, "[ERROR]: You may not give him these weapons.");
    if(slot == 1 && !IsMeleeWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid melee weapon, (1-15).");
    if(slot == 2 && !IsPrimaryWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid primary weapon, (22-24).");
    if(slot == 3 && !IsSecondaryWeapon(wepid)) return SendClientMessage(playerid, -1, "[ERROR]: Invalid secondary weapon, (25/28-32).");
    GetWeaponName(wepid, wepname, sizeof(wepname));
    if(slot == 1)
    {
        GiveMeleeWeapon(id, wepid);
    }
    else if(slot == 2)
    {
        GivePermWeapon(id, 2, wepid, ammo);
    }
    else if(slot == 3)
    {
        GivePermWeapon(id, 3, wepid, ammo);
    }
    format(msg, sizeof(msg), "[SERVER]: You've just gave %s a perm weapon, Weapon: %s, Ammo: %d. [He will now spawn with it].", GetName(id), wepname, ammo);
    SendClientMessage(playerid, COLOR_LIGHTGREEN, msg);
    format(msg, sizeof(msg), "[SERVER]: Admin %s gave you a perm weapon, Weapon: %s, Ammo: %d. [You will now spawn with it].", GetName(playerid), wepname, ammo);
    SendClientMessage(id, COLOR_LIGHTGREEN, msg);
    format(msg, sizeof(msg), "AdmCmd: %s has just given %s a perm weapon. (%s, Ammo: %d)", GetName(playerid), GetName(id), wepname, ammo);
    AMSG(COLOR_LIGHTRED, msg);
    return 1;
}
how to convert sscanf to strcmp ?
Reply
#2

You mean from zcmd to strcmp ? sorry but why. zcmd is better!
https://sampwiki.blast.hk/wiki/Using_strcmp%28%29
Reply
#3

No , i use zcmd , but i want to convert to strcmp like this

pawn Код:
COMMAND:editplayer(playerid,params[])
{

    new idx = 0;
    if(AccountInfo[playerid][aAdmin] >= ADMIN_LVL_SUPER)
    {

        new tmp[64];
        tmp = strtok(params,idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid,COLOR_LIGHTRED,"FOLOSESTE: /editplayer [ID Jucator/Nume] [variable] [new value]");
            SendClientMessage(playerid,COLOR_LIGHTRED,"Actiuni: language, companyperms, company, deaths, carlicwarns, hotel, employed, duplicate");
            SendClientMessage(playerid,COLOR_LIGHTRED,"Actiuni: dutyskin, flylic, jobcool, paytime, weplic, carlic, jailtime, factionperms");
            SendClientMessage(playerid,COLOR_LIGHTRED,"Actiuni: payday, job, phone, faction, renting");
            return 1;
        }
        new other = ReturnUser(tmp);
        if(!IsPlayerConnectedEx(other)) { SendClientMessage(playerid,COLOR_LIGHTRED,"Acest jucator nu este conectat."); return 1; }
        new tmp2[64];
        tmp2 = strtok(params,idx);
        if(strcmp(tmp2,"language",true) == 0)
        {
.........................................
Reply
#4

UP !!
Reply
#5

Why would you want to move backwards instead of forwards no logic here.
Reply
#6

You don't really want to switch from sscanf to strcmp because sscanf is very smart and powerful plugin. You can use strcmp after you have used sscanf for i.e checking what the player has written in command for spawning weapons or something like that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)