SA-MP Forums Archive
Error and i cant understand why - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Error and i cant understand why (/showthread.php?tid=271077)



Error and i cant understand why - slymatt - 22.07.2011

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


Re: Error and i cant understand why - [MG]Dimi - 22.07.2011

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";




Re: Error and i cant understand why - slymatt - 22.07.2011

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

==


Re: Error and i cant understand why - MadeMan - 22.07.2011

pawn Код:
new Factionname[32];



Re: Error and i cant understand why - Sasino97 - 22.07.2011

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");



Re: Error and i cant understand why - slymatt - 22.07.2011

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



Re: Error and i cant understand why - slymatt - 22.07.2011

still havent worked it out =S


Re: Error and i cant understand why - Amit_B - 23.07.2011

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];



Re: Error and i cant understand why - [L3th4l] - 23.07.2011

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";
}



Re: Error and i cant understand why - slymatt - 23.07.2011

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



Re: Error and i cant understand why - MoroDan - 23.07.2011

Show me how you declared the Stats variable.


Re: Error and i cant understand why - slymatt - 23.07.2011

new Stats[5], string[150];


Re: Error and i cant understand why - MoroDan - 23.07.2011

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



Re: Error and i cant understand why - slymatt - 23.07.2011

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?


Re: Error and i cant understand why - slymatt - 26.07.2011

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