Error and i cant understand why
#1

I have this piece of code:
Код:
new Factionname;
if(PlayerInfo[playerid][Faction] == 1)
{
Factionname = "LSPD";
}
else if(PlayerInfo[playerid][Faction] == 2)
{
Factionname = "FBI";
}
else if(PlayerInfo[playerid][Faction] == 3)
{
Factionname = "S.W.A.T";
}
else if(PlayerInfo[playerid][Faction] == 4)
{
Factionname = "G5Security";
}
else if(PlayerInfo[playerid][Faction] == 5)
{
Factionname = "EMT";
}
else if(PlayerInfo[playerid][Faction] == 6)
{
Factionname = "SanNews";
}
and i cant understand why im getting these errors:
Код:
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(578) : error 006: must be assigned to an array
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(582) : error 006: must be assigned to an array
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(586) : error 006: must be assigned to an array
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(590) : error 006: must be assigned to an array
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(594) : error 006: must be assigned to an array
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(598) : error 006: must be assigned to an array
Thanks for the help
Reply
#2

try this one
PHP код:
new Factionname;
if(
PlayerInfo[playerid][Faction] == 1)
{
Factionname == "LSPD";
}
else if(
PlayerInfo[playerid][Faction] == 2)
{
Factionname == "FBI";
}
else if(
PlayerInfo[playerid][Faction] == 3)
{
Factionname == "S.W.A.T";
}
else if(
PlayerInfo[playerid][Faction] == 4)
{
Factionname == "G5Security";
}
else if(
PlayerInfo[playerid][Faction] == 5)
{
Factionname == "EMT";
}
else if(
PlayerInfo[playerid][Faction] == 6)
{
Factionname == "SanNews";

Reply
#3

Nope that doesnt work either, that is to check if something is the same as something else.

==
Reply
#4

pawn Код:
new Factionname[32];
Reply
#5

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
try this one
PHP код:
new Factionname;
if(
PlayerInfo[playerid][Faction] == 1)
{
Factionname == "LSPD";
}
else if(
PlayerInfo[playerid][Faction] == 2)
{
Factionname == "FBI";
}
else if(
PlayerInfo[playerid][Faction] == 3)
{
Factionname == "S.W.A.T";
}
else if(
PlayerInfo[playerid][Faction] == 4)
{
Factionname == "G5Security";
}
else if(
PlayerInfo[playerid][Faction] == 5)
{
Factionname == "EMT";
}
else if(
PlayerInfo[playerid][Faction] == 6)
{
Factionname == "SanNews";







Use:
pawn Код:
format(Factionname, sizeof(Factionname), "LSPD");
Reply
#6

New error:
Код:
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(585) : error 035: argument type mismatch (argument 1)
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(585) : error 035: argument type mismatch (argument 1)
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(589) : error 035: argument type mismatch (argument 1)
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(589) : error 035: argument type mismatch (argument 1)
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(589) : error 017: undefined symbol "FBI"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(589) : fatal error 107: too many error messages on one line
Reply
#7

still havent worked it out =S
Reply
#8

MadeMan is right. The variable "Factionname" have to be an array,
I guess that you got this:
pawn Код:
new Factionname;
So replace this to:
pawn Код:
new Factionname[32];
Reply
#9

pawn Код:
new
    Factionname[25];

switch(PlayerInfo[playerid][Faction])
{
    case 1: Factionname = "LSPD";
    case 2: Factionname = "FBI";
    case 3: Factionname = "S.W.A.T";
    case 4: Factionname = "G5Security";
    case 5: Factionname = "EMT";
    case 6: Factionname = "SanNews";
}
Reply
#10

No i get this error:
Код:
 error 006: must be assigned to an array
And its from here:
Код:
Stats[3] = Factionname;
Reply
#11

Show me how you declared the Stats variable.
Reply
#12

new Stats[5], string[150];
Reply
#13

then, do like this:
PHP код:
new Stats[21], string[150];
format(Stats21"%s"Factionname); 
Reply
#14

Ye but i have other variables stored in it to my codes like this:

Код:
new Factionname[25];

switch(PlayerInfo[playerid][Faction])
{
    case 1: Factionname = "LSPD";
    case 2: Factionname = "FBI";
    case 3: Factionname = "S.W.A.T";
    case 4: Factionname = "G5Security";
    case 5: Factionname = "EMT";
    case 6: Factionname = "SanNews";
}

new Stats[5], string[150];
Stats[0] = PlayerInfo[playerid][Cash];
Stats[1] = PlayerInfo[playerid][Kills];
Stats[2] = PlayerInfo[playerid][Deaths];
Stats[3] = Factionname;
Stats[4] = PlayerInfo[playerid][Factionrank];
Wont the way your telling me to do it mess my code up?
Reply
#15

i have this now

Код:
new Stats[6], string[150];
Stats[0] = PlayerInfo[playerid][Cash];
Stats[1] = PlayerInfo[playerid][Kills];
Stats[2] = PlayerInfo[playerid][Deaths];
Stats[3] = Factionname[24];
Stats[4] = PlayerInfo[playerid][Factionrank];
Stats[5] = PlayerInfo[playerid][Bankdeposit];
format(string, sizeof(string), "Account: Cash: %d || Kills: %d || Deaths: %d || Faction: %d || Faction Rank: %d || Bank Balance: %d", Stats[0], Stats[1], Stats[2], Stats[3], Stats[4], Stats[5]);
SendClientMessage(playerid, COLOUR_YELLOW, string);
but Stats[3] = Factionname[24]; still shows as 0 when i type /stats although in my file it is set to 1 and should show LSPD =S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)