Stock -
emokidx - 08.08.2011
hello
will this not work??
pawn Код:
stock Ranks(playerid) {
if(PlayerInfo[playerid][pKills] == 0) {
PlayerInfo[playerid][pRank] = "Wannabe";
}
else if(PlayerInfo[playerid][pKills] >= 1) {
PlayerInfo[playerid][pRank] = "Newbie";
}
return 1;
}
it gives error:
Код:
error 006: must be assigned to an array
on
pawn Код:
PlayerInfo[playerid][pRank] = "Wannabe";
and
pawn Код:
PlayerInfo[playerid][pRank] = "Newbie";
Re: Stock -
JaTochNietDan - 08.08.2011
How many cells have you assigned to the pRank variable? It would appear that you've created it as an integer rather than an array, can you show us your enumeration snippet?
Re: Stock -
emokidx - 08.08.2011
pawn Код:
enum pInfo
{
pAdminLevel,
pCash,
pScore,
pKills,
pDeaths,
pRatio,
pRank,
}
Re: Stock -
JaTochNietDan - 08.08.2011
Well there's your problem, how can you expect an integer to hold an array of characters? You need at least a 7 cell array to hold the data you're assigning to it, so you need to initialize it in the enumerator like so:
pawn Код:
enum pInfo
{
pAdminLevel,
pCash,
pScore,
pKills,
pDeaths,
pRatio,
pRank[7],
}
Re: Stock -
emokidx - 08.08.2011
oh,, i always forget to put that in strings.. and i put the size in integers sometimes.. -.-
thanx..
Re: Stock -
Sascha - 08.08.2011
yea you can... if you need that many cells
just change the number within the [] to 128
Re: Stock -
emokidx - 08.08.2011
uhm uhm uhm
when i do that this error comes D:
Код:
error 047: array sizes do not match, or destination array is too small
on the line:
pawn Код:
PlayerInfo[playerid][pRank] = "Wannabe";
Re: Stock -
Sascha - 08.08.2011
pawn Код:
format(PlayerInfo[playerid][pRank], 128, "Wannabe");
try this instead if '='
edit: oh.. following what jatochniet says below [V] I guess you mean when using "7"^^ so nvm this post
Re: Stock -
JaTochNietDan - 08.08.2011
Quote:
Originally Posted by emokidx111
uhm uhm uhm
when i do that this error comes D:
Код:
error 047: array sizes do not match, or destination array is too small
on the line:
pawn Код:
PlayerInfo[playerid][pRank] = "Wannabe";
|
Try increasing the size of the array to 8, or else just use
strcat to format the array.
Re: Stock -
emokidx - 08.08.2011
Quote:
Originally Posted by JaTochNietDan
Try increasing the size of the array to 8, or else just use strcat to format the array.
|
will see that later.. i gtg .. thankz for helping
Quote:
Originally Posted by Sascha
pawn Код:
format(PlayerInfo[playerid][pRank], 128, "Wannabe");
try this instead if '='
edit: oh.. following what jatochniet says below [V] I guess you mean when using "7"^^ so nvm this post
|
that works.. thnx..
uhm.. which is better to use btw?
Re: Stock -
Babul - 08.08.2011
i suggest you to create an array for ranks like
Код:
new Rank[][16]={"r0:Newbie","r1:Crewman","r2","r3","r4 Captain"};
and then use the arrayed rank names.
why i suggest this? imagine you want to promote/demote someone, then you would need to check for each single rank string, copmpare it, then set it to another one. by using a simple number as rank, you can easily change the numerical value, and later, when needed, print the array.
Код:
format(string,sizeof(string),"%s",Rank[PlayerInfo[playerid][pRank]]);
Код:
PlayerInfo[playerid][pRank]=0;//prints "Newbie"
PlayerInfo[playerid][pRank]=1;//prints "Crewman"
so its a simple pointer to the rank array. no need to waste large strings on saving, and you can change the rank names aswell
Re: Stock -
emokidx - 08.08.2011
uhm
the rank will be based on the kills and its not like i want to demote someone..
it wil be like if the player reaches 1313 kills he will get promoted to something like a cool shooter for e,g,.. so will that work for it too?
Re: Stock -
Babul - 08.08.2011
oh, no, my solution will fail then. a math calculation for ranks should do fine. lets say for each 100 kills, you get 1 rank added?
Код:
new RankPromotion=floatround(PlayerInfo[playerid][pKills]/100,floatround_floor);
so for each 100 kills the rank will increase by 1. iam afraid that you want to make a non ordered promotion "table" like 0 kills:rank0, 10 kills:rank1, 100 kills: rank3, 400 more kills each: rank4 etc? this would make it a bit more complex. stick to a linear interpolation for ranks, it needs 1 calculation only.
000-099 kills: still rank 0.
100-199 rank 1 etc.
due the rank divided by 100 gives a float value, the floatround_floor will make it an integer again, whcih can be used to point to the rank array.
Re: Stock -
emokidx - 09.08.2011
but i dont want it like this
watch my stock.. i want it to be like if the player is at 0 kills,, the rank will we wannabe.. and if its 1 it will go to killer... and then it will be at number of kills that i specify..
Re: Stock -
Lorenc_ - 09.08.2011
Quote:
Originally Posted by Babul
oh, no, my solution will fail then. a math calculation for ranks should do fine. lets say for each 100 kills, you get 1 rank added?
Код:
new RankPromotion=floatround(PlayerInfo[playerid][pKills]/100,floatround_floor);
so for each 100 kills the rank will increase by 1. iam afraid that you want to make a non ordered promotion "table" like 0 kills:rank0, 10 kills:rank1, 100 kills: rank3, 400 more kills each: rank4 etc? this would make it a bit more complex. stick to a linear interpolation for ranks, it needs 1 calculation only.
000-099 kills: still rank 0.
100-199 rank 1 etc.
due the rank divided by 100 gives a float value, the floatround_floor will make it an integer again, whcih can be used to point to the rank array.
|
Make sure you create it as a float otherwise it'll return a unknown number or a whole number instead of the actual output
Float = Decimal in short