I really need help seriously. -
speedruntrainer - 11.04.2009
I need help for who won the reactiontest in an amount of time and how many times a player won. I want to add it. I'm working for a week but I can't understand. please, can someone help me?
This is the code:
and for the whole script:
http://pastebin.com/f365ed4de
Код:
public ReactionWin(playerid)
{
//where you start counting:
new time_start = GetTickCount();
//where you want to know time difference:
new time_diff = GetTickCount() - time_start;
GivePlayerMoney(playerid, 10000);
SetTimer("SetBack",30,0); // required delay, for some reason.
new reactionwinner[256];
reactionwinnerid = playerid;
new tempstring[256];
GetPlayerName(playerid,reactionwinner,sizeof(reactionwinner));
SendClientMessage(playerid,0x247C1BFF,"You have won the reactiontest!");
format(tempstring,sizeof(tempstring),"%s has won the reactiontest!",reactionwinner);
SendClientMessageToAll(0xFFFF00FF,tempstring);
reactiongap = SetTimer("ReactionTest",time1+random(time2),0); // sets the timer to restart ReactionTest()
return 1;
}
at the %s has won the reactiontest! I need a time. i need to add something to it. do you know what mean? cause it's hard to explain. I want it like this:
%s has won the reactiontest in [seconds.miliseconds]! he/she won [ammount] times before.
EDIT: warning 204: symbol is assigned a value that is never used: "time_diff"
That's my time warning
Re: I really need help seriously. -
speedruntrainer - 18.04.2009
OMG Pl0x HELP!!! :@
Re: I really need help seriously. -
Backwardsman97 - 19.04.2009
I was messing with something like this the other day.
pawn Код:
new TimeDiff = (GetTickCount() - time_start) % 60000;
format(tempstring,sizeof(tempstring),"%s has won the reactiontest! (%d.%d)",reactionwinner,TimeDiff / 100, TimeDiff % 100);
Add in that and make that your format code.
Re: I really need help seriously. -
speedruntrainer - 19.04.2009
doesn't work, or maybe im doing something wrong, it says that I won in 0.0 :O
sorry, im a noob at scripting, even im reading the wiki it doesnt help
Код:
GivePlayerMoney(playerid, 10000);
SetTimer("SetBack",30,0); // required delay, for some reason.
new reactionwinner[256];
reactionwinnerid = playerid;
new tempstring[256];
GetPlayerName(playerid,reactionwinner,sizeof(reactionwinner));
SendClientMessage(playerid,0x247C1BFF,"You have won the reactiontest!");
new time_start = GetTickCount();
new TimeDiff = (GetTickCount() - time_start) % 60000;
format(tempstring,sizeof(tempstring),"%s has won the reactiontest in %d.%d",reactionwinner,TimeDiff / 100, TimeDiff % 100);
SendClientMessageToAll(0xFFFF00FF,tempstring);
reactiongap = SetTimer("ReactionTest",time1+random(time2),0); // sets the timer to restart ReactionTest()
return 1;
I tried a lot but didnt work, and I really need it in my server
Re: I really need help seriously. -
Backwardsman97 - 19.04.2009
pawn Код:
GivePlayerMoney(playerid, 10000);
SetTimer("SetBack",30,0); // required delay, for some reason.
new reactionwinner[24] ,string[128];
GetPlayerName(playerid,reactionwinner,24);
SendClientMessage(playerid,0x247C1BFF,"You have won the reactiontest!");
new TimeDiff = (GetTickCount() - time_start) % 60000;
format(string,128,"%s has won the reactiontest in %d.%d",reactionwinner,TimeDiff / 100, TimeDiff % 100);
SendClientMessageToAll(0xFFFF00FF,string);
reactiongap = SetTimer("ReactionTest",time1+random(time2),0); // sets the timer to restart ReactionTest()
return 1;
If the time part doesn't work it means you must have set time_start wrong.
Re: I really need help seriously. -
speedruntrainer - 19.04.2009
still 0.0 really. this is the WHOLE script:
Код:
#include <a_samp>
#define time1 120000 //this is the 1 minute minimum gap time
#define time2 120000 // this is the 1 minute max addon time
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" ReactiontestFS by tomozj");
print("--------------------------------------\n");
SetTimer("ReactionTest",time1+random(time2),0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
new reactionstr[9]; //randomly generated string
new reactioninprog; //what status the reactiontest is at
new reactionwinnerid; //id of the current reactiontest winner
new reactiongap; //timer to restart ReactionTest()
forward ReactionTest();
forward ReactionWin(playerid);
forward SetBack();
public OnPlayerText(playerid, text[])
{
if(!strcmp(text, reactionstr, false))
{
if(reactioninprog == 2) ReactionWin(playerid);
if(reactioninprog == 1)
{
if(reactionwinnerid == playerid)
{
SendClientMessage(playerid,0x247C1BFF,"You've already won!");
}
else
{
SendClientMessage(playerid,0x247C1BFF,"You are too slow!");
}
}
return 1;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!IsPlayerAdmin(playerid)) return 0; // if player isn't admin, ignore cmds
if (strcmp("/test", cmdtext, true, 10) == 0)
{
ReactionTest();
return 1;
}
if (strcmp("/output reactionstr", cmdtext, true, 10) == 0)
{
new tmp[256];
format(tmp,sizeof(tmp),"'reactionstr' output: %d",reactionstr);
SendClientMessageToAll(0x247C1BFF,tmp);
return 1;
}
return 0;
}
public ReactionTest()
{
reactionstr = "";
KillTimer(reactiongap);
new str[256];
new random_set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // the set of characters used for the generation of the string
for (new i = 0; i < 8; i++)
{
reactionstr[i] = random_set[random(sizeof(random_set))];
}
reactioninprog = 2;
format(str,sizeof(str),"** First one to type %s wins $10,000!",reactionstr); // announcement
print(str);
SendClientMessageToAll(0xFFFF00FF,str);
}
public ReactionWin(playerid)
{
new time_start = GetTickCount();
//where you want to know time difference:
GivePlayerMoney(playerid, 10000);
SetTimer("SetBack",30,0); // required delay, for some reason.
new reactionwinner[24] ,string[128];
GetPlayerName(playerid,reactionwinner,24);
SendClientMessage(playerid,0x247C1BFF,"You have won the reactiontest!");
new TimeDiff = (GetTickCount() - time_start) % 60000;
format(string,128,"%s has won the reactiontest in %d.%d!",reactionwinner,TimeDiff / 100, TimeDiff % 100);
SendClientMessageToAll(0xFFFF00FF,string);
reactiongap = SetTimer("ReactionTest",time1+random(time2),0); // sets the timer to restart ReactionTest()
return 1;
}
public SetBack()
{
reactioninprog = 1;
}