Hello everyone, i have faced a bug with my rank system i tried to fix it but i failed
idk what's going on.. here is the code:
Код HTML:
if(GetPlayerScore(playerid) >= 0 && strcmp(AccData[playerid][pRank], "No Rank", true) < 50)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Newbie");
strcat(AccData[playerid][pRank],"Newbie");
}
else if(GetPlayerScore(playerid) >= 50 && strcmp(AccData[playerid][pRank], "Newbie", true) < 100)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Pro");
strcat(AccData[playerid][pRank],"Pro");
}
else if(GetPlayerScore(playerid) >= 100 && strcmp(AccData[playerid][pRank], "Pro", true) < 200)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Chump");
strcat(AccData[playerid][pRank],"Chump");
}
else if(GetPlayerScore(playerid) >= 200 && strcmp(AccData[playerid][pRank], "Chump", true) < 400)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Killah");
strcat(AccData[playerid][pRank],"Killah");
}
else if(GetPlayerScore(playerid) >= 400 && strcmp(AccData[playerid][pRank], "Killah", true) < 800)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Serial Killah");
strcat(AccData[playerid][pRank],"Serial Killah");
}
else if(GetPlayerScore(playerid) >= 800 && strcmp(AccData[playerid][pRank], "Serial Killah", true) < 1000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced");
strcat(AccData[playerid][pRank],"Advanced");
}
else if(GetPlayerScore(playerid) >= 1000 && strcmp(AccData[playerid][pRank], "Advanced", true) < 1500)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced Serial Killah");
strcat(AccData[playerid][pRank],"Advanced Serial Killah");
}
else if(GetPlayerScore(playerid) >= 1500 && strcmp(AccData[playerid][pRank], "Advanced Serial Killah", true) < 2000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Blood Reaper");
strcat(AccData[playerid][pRank],"Blood Reaper");
}
else if(GetPlayerScore(playerid) >= 2000 && strcmp(AccData[playerid][pRank], "Blood Reaper", true) < 2500)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced Blood Reaper");
strcat(AccData[playerid][pRank],"Advanced Blood Reaper");
}
else if(GetPlayerScore(playerid) >= 2500 && strcmp(AccData[playerid][pRank], "Advanced Blood Reaper", true) < 3000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Blood Liner");
strcat(AccData[playerid][pRank],"Blood Liner");
}
else if(GetPlayerScore(playerid) >= 3000 && strcmp(AccData[playerid][pRank], "Blood Liner", true) < 3500)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced Blood Liner");
strcat(AccData[playerid][pRank],"Advanced Blood Liner");
}
else if(GetPlayerScore(playerid) >= 3500 && strcmp(AccData[playerid][pRank], "Advanced Blood Liner", true) < 4000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Death Reaper");
strcat(AccData[playerid][pRank],"Death Reaper");
}
else if(GetPlayerScore(playerid) >= 4000 && strcmp(AccData[playerid][pRank], "Death Reaper", true) < 5000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced Death Reaper");
strcat(AccData[playerid][pRank],"Advanced Death Reaper");
}
else if(GetPlayerScore(playerid) >= 5000 && strcmp(AccData[playerid][pRank], "Advanced Death Reaper", true) < 6000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Head Seeker");
strcat(AccData[playerid][pRank],"Head Seeker");
}
else if(GetPlayerScore(playerid) >= 6000 && strcmp(AccData[playerid][pRank], "Head Seeker", true) < 7000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced Head Seeker");
strcat(AccData[playerid][pRank],"Advanced Head Seeker");
}
else if(GetPlayerScore(playerid) >= 7000 && strcmp(AccData[playerid][pRank], "Advanced Head Seeker", true) < 8000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Monster");
strcat(AccData[playerid][pRank],"Monster");
}
else if(GetPlayerScore(playerid) >= 8000 && strcmp(AccData[playerid][pRank], "Monster", true) < 9000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Hungry Monster");
strcat(AccData[playerid][pRank],"Hungry Monster");
}
else if(GetPlayerScore(playerid) > 9000 && strcmp(AccData[playerid][pRank], "Hungry Monster", true) < 10000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "God Like");
strcat(AccData[playerid][pRank],"God Like");
}
else if(GetPlayerScore(playerid) >= 10000 && strcmp(AccData[playerid][pRank], "God Like", true) < 15000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "God");
strcat(AccData[playerid][pRank],"God");
}
else if(GetPlayerScore(playerid) >= 15000 && strcmp(AccData[playerid][pRank], "God", true) < 20000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "God Of Death");
strcat(AccData[playerid][pRank],"God Of Death");
}
else if(GetPlayerScore(playerid) >= 20000 && strcmp(AccData[playerid][pRank], "God Of Death", true) < 25000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Ultimate God Of Death");
strcat(AccData[playerid][pRank],"Ultimate God Of Death");
}
else if(GetPlayerScore(playerid) >= 25000 && strcmp(AccData[playerid][pRank], "Ultimate God Of Death", true) < 30000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Advanced God Of Death");
strcat(AccData[playerid][pRank],"Advanced God Of Death");
}
else if(GetPlayerScore(playerid) >= 30000 && strcmp(AccData[playerid][pRank], "Advanced God Of Death", true) < 55000)
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Super Advanced God Of Death");
strcat(AccData[playerid][pRank],"Super Advanced God Of Death");
}
else if(GetPlayerScore(playerid) >= 55000 && strcmp(AccData[playerid][pRank], "Super Advanced God Of Death", true))
{
dini_Set(AddDirFile("users", GetName(playerid)), "rank", "Over God");
strcat(AccData[playerid][pRank],"Over God");
}
the problem is, the rank gets stuck with newbie even if i change my score and kill myself to respawn again the rank never changes.
Why not have actual numerical ranks, use them, and simply have the rank names defined in defines?
Rather than storing the rank name itself as a string into the userfile. And do you even load the data from the userfile after you've actually changed rank, as usually you only save, you don't reload the user info from the ini file.
strcat...