help OnPlayerText if(text[0] == error
#1

why i am i getting this error?




PHP код:
C:\Users\Elvis JR\Desktop\CNR-rp\gamemodes\1.2.pwn(3703) : error 027invalid character constant
C
:\Users\Elvis JR\Desktop\CNR-rp\gamemodes\1.2.pwn(3703) : error 027invalid character constant
C
:\Users\Elvis JR\Desktop\CNR-rp\gamemodes\1.2.pwn(3703 -- 3704) : error 029invalid expressionassumed zero
C
:\Users\Elvis JR\Desktop\CNR-rp\gamemodes\1.2.pwn(3703 -- 3704) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

my code


PHP код:
if(IsPlayerInDynamicCP(playerid,Checkpoint[4]))
    {
        if(
text[0] == '1')
        {
            
GivePlayerWeapon(playerid22300);
            
GivePlayerMoney(playerid, - 1000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a 9mm with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '2')
        {
            
GivePlayerWeapon(playerid24300);
            
GivePlayerMoney(playerid, - 2000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Desert Eagle with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '3')
        {
            
GivePlayerWeapon(playerid23300);
            
GivePlayerMoney(playerid, - 3000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Silenced 9mm with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '4')
        {
            
GivePlayerWeapon(playerid25300);
            
GivePlayerMoney(playerid, - 4000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Shutgun with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '5')
        {
            
GivePlayerWeapon(playerid26300);
            
GivePlayerMoney(playerid, - 5000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Sawnoff Shotgun with 300 Bullets.");
            return 
0;
        }
          if(
text[0] == '6')
        {
            
GivePlayerWeapon(playerid27300);
            
GivePlayerMoney(playerid, - 6000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Combat Shotgun with 300 Bullets.");
            return 
0;
        }
           if(
text[0] == '7')
        {
            
GivePlayerWeapon(playerid28300);
            
GivePlayerMoney(playerid, - 7000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Micro SMG/Uzi with 300 Bullets.");
            return 
0;
        }
           if(
text[0] == '8')
        {
            
GivePlayerWeapon(playerid29300);
            
GivePlayerMoney(playerid, - 8000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a MP5 with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '9')
        {
            
GivePlayerWeapon(playerid32300);
            
GivePlayerMoney(playerid, - 9000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Tec-9 with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '10')
        {
            
GivePlayerWeapon(playerid31300);
            
GivePlayerMoney(playerid, - 10000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a M4 with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '11')
        {
            
GivePlayerWeapon(playerid30300);
            
GivePlayerMoney(playerid, - 11000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Ak47 with 300 Bullets.");
            return 
0;
        }
         if(
text[0] == '12')
        {
            
SetPlayerArmour(playerid100);
            
GivePlayerMoney(playerid, - 9000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought Armour with 100%.");
            return 
0;
        }
         if(
text[0] == '13')
        {
            
GivePlayerWeapon(playerid33300);
            
GivePlayerMoney(playerid, - 12000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Country Rifle with 300 Bullets.");
            return 
0;
        }
        if(
text[0] == '14')
        {
            
GivePlayerWeapon(playerid34300);
            
GivePlayerMoney(playerid, - 13000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Sniper Rifle with 300 Bullets.");
            return 
0;
        }
        else return 
1;
    } 
Reply
#2

Text is a string, use strcmp to compare them.
== is for integers and floats.

pawn Код:
if (!strcmp(text[0], "1", true))
or
pawn Код:
if (strcmp(text[0], "1", true) == 0)
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Text is a string, use strcmp to compare them.
== is for integers and floats.

pawn Код:
if (!strcmp(text[0], "1", true))
or
pawn Код:
if (strcmp(text[0], "1", true) == 0)
thanks alot man! +rep

PHP код:
    if(IsPlayerInDynamicCP(playerid,Checkpoint[4]))
    {
        if (!
strcmp(text"1"true))
        {
            
GivePlayerWeapon(playerid22300);
            
GivePlayerMoney(playerid, - 1000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a 9mm with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"2"true))
        {
            
GivePlayerWeapon(playerid24300);
            
GivePlayerMoney(playerid, - 2000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Desert Eagle with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"3"true))
        {
            
GivePlayerWeapon(playerid23300);
            
GivePlayerMoney(playerid, - 3000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Silenced 9mm with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"4"true))
        {
            
GivePlayerWeapon(playerid25300);
            
GivePlayerMoney(playerid, - 4000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Shutgun with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"5"true))
        {
            
GivePlayerWeapon(playerid26300);
            
GivePlayerMoney(playerid, - 5000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Sawnoff Shotgun with 300 Bullets.");
            return 
0;
        }
          if (!
strcmp(text"6"true))
        {
            
GivePlayerWeapon(playerid27300);
            
GivePlayerMoney(playerid, - 6000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Combat Shotgun with 300 Bullets.");
            return 
0;
        }
           if (!
strcmp(text"7"true))
        {
            
GivePlayerWeapon(playerid28300);
            
GivePlayerMoney(playerid, - 7000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Micro SMG/Uzi with 300 Bullets.");
            return 
0;
        }
           if (!
strcmp(text"8"true))
        {
            
GivePlayerWeapon(playerid29300);
            
GivePlayerMoney(playerid, - 8000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a MP5 with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"9"true))
        {
            
GivePlayerWeapon(playerid32300);
            
GivePlayerMoney(playerid, - 9000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Tec-9 with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"10"true))
        {
            
GivePlayerWeapon(playerid31300);
            
GivePlayerMoney(playerid, - 10000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a M4 with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"11"true))
        {
            
GivePlayerWeapon(playerid30300);
            
GivePlayerMoney(playerid, - 11000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Ak47 with 300 Bullets.");
            return 
0;
        }
         if (!
strcmp(text"12"true))
        {
            
SetPlayerArmour(playerid100);
            
GivePlayerMoney(playerid, - 9000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought Armour with 100%.");
            return 
0;
        }
         if (!
strcmp(text"13"true))
        {
            
GivePlayerWeapon(playerid33300);
            
GivePlayerMoney(playerid, - 12000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Country Rifle with 300 Bullets.");
            return 
0;
        }
        if (!
strcmp(text"14"true))
        {
            
GivePlayerWeapon(playerid34300);
            
GivePlayerMoney(playerid, - 13000);
            
SendClientMessage(playerid0x35CA8BFF"You have Bought a Sniper Rifle with 300 Bullets.");
            return 
0;
        }
        else return 
1;
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)