Strcmp help...
#1

Hey, I've made a /buy command, but there is a problem. It's scripted so that ex. "/buy headset" will buy a headset, but if you instead type "/buy HeaDsEt" it sends the error message...

How to change?


pawn Код:
dcmd_buy(playerid,params[])
{
  new pName[MAX_PLAYER_NAME], File[256],string[256],prox[256];
    GetPlayerName(playerid,pName,sizeof(pName));
  format(File,sizeof(File),"CLRP/Players/%s.ini",pName);
  new value[256];
  if(PlayerInfo[playerid][pShop] == 0 && PlayerInfo[playerid][pAmmunation] == 0) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: You're not in a shop :.");
    if(PlayerInfo[playerid][pShop] == 1)
    {
      if(sscanf(params,"s",value))
        {
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"Radio[$85] - PDA[$800] - Headset[$100]");
            SendClientMessage(playerid,COLOR_LIGHTBLUE,".: Usage: /buy [item] :.");
            return 1;
        }
        if(strcmp(params,"radio") && strcmp(params,"pda") && strcmp(params,"headset"))
        {
          SendClientMessage(playerid,COLOR_LIGHTBLUE,"Radio[$85] - PDA[$800] - Headset[$100]");
            SendClientMessage(playerid,COLOR_LIGHTBLUE,".: Usage: /buy [item] :.");
            return 1;
        }
        if(!strcmp(params,"radio"))
        {
          if(PlayerInfo[playerid][pMoney] < 85) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: Not enough money :.");
          dini_IntSet(File,"Radio",1);
            PlayerInfo[playerid][pRadio] = 1;
            new difference = PlayerInfo[playerid][pMoney] - 85;
            PlayerInfo[playerid][pMoney] = difference;
            format(string,256,".: Info: You bought a Radio for 85$, new wallet amount: $%d",PlayerInfo[playerid][pMoney]);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            return 1;
        }
        if(!strcmp(params,"headset"))
        {
          if(PlayerInfo[playerid][pRadio] == 0) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: You need a radio first :.");
          if(PlayerInfo[playerid][pMoney] < 100) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: Not enough money :.");
          dini_IntSet(File,"Headset",1);
            PlayerInfo[playerid][pHeadset] = 1;
            new difference = PlayerInfo[playerid][pMoney] - 100;
            PlayerInfo[playerid][pMoney] = difference;
            format(string,256,".: Info: You bought a Headset for 100$, new wallet amount: $%d",PlayerInfo[playerid][pMoney]);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            return 1;
        }
    if(!strcmp(params,"pda"))
        {
          if(PlayerInfo[playerid][pMoney] < 800) return SendClientMessage(playerid,COLOR_DARKRED,".: Info: Not enough money :.");
          dini_IntSet(File,"PDA",1);
            PlayerInfo[playerid][pPDA] = 1;
            new difference = PlayerInfo[playerid][pMoney] - 800;
            PlayerInfo[playerid][pMoney] = difference;
            format(string,256,".: Info: You bought a PDA for 800$, new wallet amount: $%d",PlayerInfo[playerid][pMoney]);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            return 1;
        }
    }
Help please =)
Reply
#2

Look the function definition.

pawn Код:
strcmp(const string1[], const string2[], bool:ignorecase=false, length=cellmax);
Just set ignorecase to true.
Reply
#3

Oh lol... Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)