What's wrong with this script?
#1

I wanted to create achievements for my racing gamemode .
pawn Код:
OnPlayerUpdate(playerid)
{
    new string[100];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    if(GetPlayerScore(playerid) >=100)
    {
    format(string,sizeof(string),"%s reached 100 score and received 100,000$",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 100000);
    }
    if(GetPlayerScore(playerid) >=250)
    {
    format(string,sizeof(string),"%s reached 250 score and received 250,000$",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 250000);
    }
    if(GetPlayerScore(playerid) >=500)
    {
    format(string,sizeof(string),"%s reached 500 score and received 500,000$,and VIP status",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 500000);
    }
    if(GetPlayerScore(playerid) >=1000)
    {
    format(string,sizeof(string),"%s reached 1000 score and received 1,000,000$",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 1000000);
    }
    if(GetPlayerScore(playerid) >=2500)
    {
    format(string,sizeof(string),"%s reached 250 score and received 2,500,000$",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 2500000);
    }
    if(GetPlayerScore(playerid) >=5000)
    {
    format(string,sizeof(string),"%s reached 500 score and received 5,000,000$",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 250000);
    }
    if(GetPlayerScore(playerid) >=10000)
    {
    format(string,sizeof(string),"%s reached 10000 score and received 10,000,000%",pname);
    SendClientMessageToAll(COLOR_LIGHTBLUE,string);
    GivePlayerMoney(playerid, 10000000);
    }
        return 1;
}
pawn Код:
CMD:achievements(playerid,params[])
{
    //SendClientMessage(playerid,COLOR_RED,"This page is under construction");
    ShowPlayerDialog(playerid, 95, DIALOG_STYLE_MSGBOX, "Achievement Menu","Achievement - Reward - Special\n100 score - 100,000$\n 250 score - 250,000$ 500 score - 500,000 - VIP\n 1000 score - 1,000,000$\n 2500 score - 2,500,000$\n5000 score - 5,000,000$\n 10000 score - 10,000,000","OK","");
    return 1;
}
I dont know whats wrong but when someone reaches 100 score,the chat is being spammed by the custom messages and he receives his money more than he should to.
Reply
#2

Try using else if statement.
Reply
#3

if(GetPlayerScore(playerid) >=100)

to

if(GetPlayerScore(playerid) == 100)

Do it on each line.
Reply
#4

LOL why OnPlayerUpdate ?
Reply
#5

Quote:
Originally Posted by HuSs3n
Посмотреть сообщение
LOL why OnPlayerUpdate ?
Where should i put it?
Note: i tried == ,still the same thing,he receives his money every second instant of one time,and the messages spam the chat every second.
Reply
#6

Well if you have the command opening a dialog you should put in under OnDilaogResponse!
Reply
#7

it opens on a msgbox not in a list so there's no need to put it under OnDialogResponse.....
If i there's no solution about the current code,i will request an /achievements script on the script request thread 5
Reply
#8

Think logically. OnPlayerUpdate is very frequent, and the condition is true on every call. You need to mark that user already got the achievement.
Reply
#9

And how will i do that?
NOTE: Im a scripter so i dont know how.
Reply
#10

Quote:
Originally Posted by Johnson_Brooks
Посмотреть сообщение
And how will i do that?
NOTE: Im a scripter so i dont know how.
When you increase someones score, THEN check what rank they are. Also use == instead of >=
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)