SA-MP Forums Archive
commands problem - 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: commands problem (/showthread.php?tid=460082)



commands problem - martoivanov - 26.08.2013

Can someone help me with this command? It doesn't work
pawn Код:
if (!strcmp("/gun", cmd, true)) {
                tmp = strtok(cmdtext, idx);
                if(BusinessInfo[InsideBiz[playerid]][bType] != 5) return SendClientMessage(playerid, COLOR_RED, "sth!");
                if (!strlen(tmp)) {
                        SendClientMessage(playerid, 0x00E800FF, "Usage: /gun [name] (shotgun,uzi,mp5,ak47,m4,sniper)");
                        return 1;
                }
                if (!strcmp(tmp, "shotgun", true)) GivePlayerWeapon(playerid,249,600);
                else if (!strcmp(tmp, "uzi", true)) GivePlayerWeapon(playerid,352,600);
                else if (!strcmp(tmp, "mp5", true)) GivePlayerWeapon(playerid,353,600);
                else if (!strcmp(tmp, "ak47", true)) GivePlayerWeapon(playerid,355,600);
                else if (!strcmp(tmp, "m4", true)) GivePlayerWeapon(playerid,356,600);
                else if (!strcmp(tmp, "sniper", true)) GivePlayerWeapon(playerid,358,600);
                else SendClientMessage(playerid, 0x00E800FF, "Invalid weapon!");
                GivePlayerMoney(playerid,-200);
                BusinessInfo[InsideBiz[playerid]][bMoney] += 200;
                return 1;
        }



Re: commands problem - Slepur - 26.08.2013

pawn Код:
if (strcmp("/gun", cmd, true)) {
                tmp = strtok(cmdtext, idx);
                if(BusinessInfo[InsideBiz[playerid]][bType] != 5) return SendClientMessage(playerid, COLOR_RED, "sth!");
                if (!strlen(tmp)) {
                        SendClientMessage(playerid, 0x00E800FF, "Usage: /gun [name] (shotgun,uzi,mp5,ak47,m4,sniper)");
                        return 1;
                }
                if (strcmp(tmp, "shotgun", true)) GivePlayerWeapon(playerid,249,600);
                else if (strcmp(tmp, "uzi", true)) GivePlayerWeapon(playerid,352,600);
                else if (strcmp(tmp, "mp5", true)) GivePlayerWeapon(playerid,353,600);
                else if (strcmp(tmp, "ak47", true)) GivePlayerWeapon(playerid,355,600);
                else if (strcmp(tmp, "m4", true)) GivePlayerWeapon(playerid,356,600);
                else if (strcmp(tmp, "sniper", true)) GivePlayerWeapon(playerid,358,600);
                else SendClientMessage(playerid, 0x00E800FF, "Invalid weapon!");
                GivePlayerMoney(playerid,-200);
                BusinessInfo[InsideBiz[playerid]][bMoney] += 200;
                return 1;
        }



Re: commands problem - martoivanov - 26.08.2013

It doesn't work


Re: commands problem - EiresJason - 26.08.2013

Is it giving you the weapon but not taking away the money from the player and giving it to the business?


Re: commands problem - DanishHaq - 26.08.2013

pawn Код:
if(strcmp("/gun", cmd, true))
{
    tmp = strtok(cmdtext, idx);
    if(BusinessInfo[InsideBiz[playerid]][bType] != 5) return SendClientMessage(playerid, COLOR_RED, "sth!");
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, 0x00E800FF, "Usage: /gun [name] (shotgun, uzi, mp5, ak47, m4, sniper)");
        return 1;
    }
    if(strcmp(tmp, "shotgun", true)) { GivePlayerWeapon(playerid, 249, 600); SendClientMessage(playerid, 0x00E800FF, "You bought a Shotgun."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else if(strcmp(tmp, "uzi", true)) { GivePlayerWeapon(playerid, 352, 600); SendClientMessage(playerid, 0x00E800FF, "You bought an Uzi."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else if(strcmp(tmp, "mp5", true)) { GivePlayerWeapon(playerid, 353, 600); SendClientMessage(playerid, 0x00E800FF, "You bought an MP5."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else if(strcmp(tmp, "ak47", true)) { GivePlayerWeapon(playerid, 355, 600); SendClientMessage(playerid, 0x00E800FF, "You bought an AK47."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else if(strcmp(tmp, "m4", true)) { GivePlayerWeapon(playerid, 356, 600); SendClientMessage(playerid, 0x00E800FF, "You bought an M4."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else if(strcmp(tmp, "sniper", true)) { GivePlayerWeapon(playerid, 358, 600); SendClientMessage(playerid, 0x00E800FF, "You bought a Sniper."); GivePlayerMoney(playerid, -200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; return 1; }
    else { SendClientMessage(playerid, 0x00E800FF, "Invalid weapon!"); }
    return 1;
}
Try this. By the way, even if the weapon was invalid, that code was still taking $200 and putting it in the business... I fixed that above.