Question
#1

I do 2 commands,/heal [playerid] [amount] and /pay [playerid] [amount] ,but when i try to use him,seems to /heal = /pay,at /heal says "Usage: /pay ....." , the question is Why?
Here is the code:
pawn Код:
new cmd[128];
            if (strcmp(cmd, "/pay", true) == 0) {
            new idx;
            cmd = strtok(cmdtext, idx);
            new tmp[256], tmp2[256];
            tmp = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);

            if(!strlen(tmp)) {
               SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pay [playerid] [amount]");
               return 1;
            }
           
            if(!strlen(tmp2)) {
               SendClientMessage(playerid, COLOR_YELLOW, "Usage: /pay [playerid] [amount]");
               return 1;
            }
           
            new receiver, money;
            receiver = strval(tmp);
            money = strval(tmp2);
           
            if(GetPlayerMoney(playerid) < money) {
                SendClientMessage(playerid, COLOR_YELLOW, "You don't have enough money !");
                return 1;
            }
           
            new string[128];
            new playername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername, sizeof(playername));
            new playername2[MAX_PLAYER_NAME];
            GetPlayerName(receiver, playername2, sizeof(playername2));
           
            format(string, sizeof(string), "You receive $%d from %s.", money, playername);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            format(string, sizeof(string), "You give $%d to %s.", money, playername2);
            SendClientMessage(playerid, COLOR_YELLOW, string);
           
            GivePlayerMoney(playerid, (0 - money));
            GivePlayerMoney(receiver, money);
           
            return 1;

            }
            if (strcmp(cmd, "/heal", true) == 0) {
            new idx;
            new tmp[256], tmp2[256];
            tmp = strtok(cmdtext, idx);
            tmp2 = strtok(cmdtext, idx);

            if(!strlen(tmp)) {
               SendClientMessage(playerid, COLOR_YELLOW, "Usage: /heal [playerid] [amount]");
               return 1;
            }

            if(!strlen(tmp2)) {
               SendClientMessage(playerid, COLOR_YELLOW, "Usage: /heal [playerid] [amount]");
               return 1;
            }

            new victim, health;
            victim = strval(tmp);
            health = strval(tmp2);

            new Float:Health;
            GetPlayerHealth(victim, Health);

            if(Health == 100) {
                SendClientMessage(playerid, COLOR_LIGHTRED, "Pacientul este sanatos tun,nu are nevoie de ajutor medical!");
                return 1;
            }

            new string[128];
            new playername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername, sizeof(playername));
            new playername2[MAX_PLAYER_NAME];
            GetPlayerName(victim, playername2, sizeof(playername2));

            format(string, sizeof(string),"%s te-a vindecat,acum ai +%d % mai multe sanse de viata", playername, health);
            SendClientMessage(victim, COLOR_LIGHTRED, string);
            SetPlayerHealth(victim, Health+Health);

            format(string, sizeof(string),"L-ai vindecat pe %s,acum are mai multe sanse de viata( +%d % )", playername2, health);
            SendClientMessage(playerid, COLOR_LIGHTRED, string);

            if((Health + health) > 100) {
            SetPlayerHealth(victim, 100);
            }

            return 1;
   }
Rep.
Reply
#2

Where is cmd (the variable) getting it's definition? strcmp will return a "0" if either string it's comparing is empty.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)