[HELP] Please take a look
#1

pawn Код:
dcmd_buygun(playerid, params[])
{
  new stringParameter[128], str[256], prize = 0;
  if(PlayerInfo[playerid][pLocal] == 1)
  {
      if(sscanf(params, "s ", stringParameter))
      {
            if(strfind(stringParameter, "knuckels", true) != -1)
            {
              prize = 2300;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $2300");
              GivePlayerWeapon(playerid, 1, 1);
            }
            if(strfind(stringParameter, "bat", true) != -1)
            {
              prize = 2500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $2500");
              GivePlayerWeapon(playerid, 5, 1);
            }
            if(strfind(stringParameter, "knife", true) != -1)
            {
              prize = 2900;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $2900");
              GivePlayerWeapon(playerid, 4, 1);
            }
            if(strfind(stringParameter, "chainsaw", true) != -1)
            {
              prize = 4500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $4500");
              GivePlayerWeapon(playerid, 9, 1);
            }
            if(strfind(stringParameter, "molotov", true) != -1)
            {
              prize = 6000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $6000");
              GivePlayerWeapon(playerid, 18, 2);
            }
            if(strfind(stringParameter, "9mm", true) != -1)
            {
              prize = 8400;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $8400");
              GivePlayerWeapon(playerid, 22, 50);
            }
            if(strfind(stringParameter, "silenced", true) != -1)
            {
              prize = 8500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $8500");
              GivePlayerWeapon(playerid, 23, 50);
            }
            if(strfind(stringParameter, "deagle", true) != -1)
            {
              prize = 11000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $11000");
              GivePlayerWeapon(playerid, 24, 50);
            }
            if(strfind(stringParameter, "shotgun", true) != -1)
            {
              prize = 16000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $16000");
              GivePlayerWeapon(playerid, 25, 25);
            }
            if(strfind(stringParameter, "sawnoff", true) != -1)
            {
              prize = 22000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $22000");
              GivePlayerWeapon(playerid, 26, 25);
            }
            if(strfind(stringParameter, "combat", true) != -1)
            {
              prize = 26000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $26000");
              GivePlayerWeapon(playerid, 27, 25);
            }
            if(strfind(stringParameter, "smg", true) != -1)
            {
              prize = 14500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $14500");
              GivePlayerWeapon(playerid, 28, 150);
            }
            if(strfind(stringParameter, "mp5", true) != -1)
            {
              prize = 18900;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $18900");
              GivePlayerWeapon(playerid, 29, 150);
            }
            if(strfind(stringParameter, "ak", true) != -1)
            {
              prize = 36000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $36000");
              GivePlayerWeapon(playerid, 30, 150);
            }
            if(strfind(stringParameter, "m4", true) != -1)
            {
              prize = 55000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $55000");
              GivePlayerWeapon(playerid, 31, 150);
            }
            if(strfind(stringParameter, "tec9", true) != -1)
            {
              prize = 16000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $16000");
              GivePlayerWeapon(playerid, 32, 150);
            }
            if(strfind(stringParameter, "sniper", true) != -1)
            {
              prize = 24500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $24500");
              GivePlayerWeapon(playerid, 34, 30);
            }
            if(strfind(stringParameter, "spray", true) != -1)
            {
              prize = 500;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $500");
              GivePlayerWeapon(playerid, 41, 150);
            }
            if(strfind(stringParameter, "rpg", true) != -1)
            {
              prize = 150000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $150.000");
              GivePlayerWeapon(playerid, 35, 3);
            }
            if(strfind(stringParameter, "flame", true) != -1)
            {
              prize = 150000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $150.000");
              GivePlayerWeapon(playerid, 37, 20);
            }
            if(strfind(stringParameter, "minigun", true) != -1)
            {
              prize = 1000000;
                if(GetPlayerMoney(playerid) < prize) return SendClientMessage(playerid, GREY,"[SERVER]: Price: $1.000.000");
              GivePlayerWeapon(playerid, 38, 1000);
            }
            GivePlayerMoney(playerid, -prize);
            format(str, 256, "[SUCCESS]: You bought %s for $%d.", stringParameter, prize);
            return SendClientMessage(playerid, GREEN, str);
        }
        else
        {
        SendClientMessage(playerid, RED,"Usage: /buygun [weaponname]");
        SendClientMessage(playerid, GREY,"| knuckels - bat - knife - chainsaw - molotov");
        SendClientMessage(playerid, GREY,"| 9mm - silenced - deagle - shotgun - sawnoff");
        SendClientMessage(playerid, GREY,"| combat - smg - mp5 - ak - m4 - tec9 - sniper");
        SendClientMessage(playerid, GREY,"| spray - rpg - flame - minigun");
        }
    }
    return SendClientMessage(playerid, RED,"[ERROR]: You're not in a Gun shop.");
}
So, this is what I use.
And if You type /buygun it shows: "You bougt for $ ."
But it works if you type /buygun mp5 etc.

Please tell me what's wrong, I've tried adding the list under if(sscanf....
but than only the list kept showing...
Reply
#2

You don't need sscanf for one parameter. And you should use strcmp instead of strfind. Try this. http://pastebin.com/m589a0669
Reply
#3

Quote:
Originally Posted by Backwardsman97
You don't need sscanf for one parameter. And you should use strcmp instead of strfind. Try this. http://pastebin.com/m589a0669
Now it gives me the wrong weapon at the wrong name , wrong ammo and wrong price :S
Reply
#4

Quote:

You don't need sscanf for one parameter. And you should use strcmp instead of strfind. Try this. http://pastebin.com/m589a0669[


Now it gives me the wrong weapon at the wrong name , wrong ammo and wrong price :S

lol fail :S
Reply
#5

Quote:
Originally Posted by BiG_Sm0k3
Quote:

You don't need sscanf for one parameter. And you should use strcmp instead of strfind. Try this. http://pastebin.com/m589a0669[


Now it gives me the wrong weapon at the wrong name , wrong ammo and wrong price :S

lol fail :S
Indeed.
Reply
#6

Oh my bad. I was thrown off by you using sscanf. http://pastebin.com/m6c8be2d1 Try that. That's the only I can think of fixing the logic error.
Reply
#7

omg backwards ur a machine :P
Reply
#8

Quote:
Originally Posted by Backwardsman97
Oh my bad. I was thrown off by you using sscanf. http://pastebin.com/m6c8be2d1 Try that. That's the only I can think of fixing the logic error.
worked , thanks alot!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)