Need help with newbie chat -
Rivermate - 09.03.2010
Hello, I want to make a newbie chat, but to prefend spam.
I want to add a cool down time; 50 seconds waiting before you can ask a /n question again, just like in SA-RP.
How can I do this?
Re: Need help with newbie chat -
Onyx09 - 09.03.2010
just make a chat with a timer ? that eaasy
Re: Need help with newbie chat -
Mike Garber - 10.03.2010
Quote:
Originally Posted by [GM
LeGenDy ]
just make a chat with a timer ? that eaasy
|
Ofcourse It's easy for us to do, but we already know how to script.
This guy doesn't and you shouldn't say that It's easy.
You're not better then this guy just because you know how to do It.
Try to help this guy instead of just telling him that It's easy.
Re: Need help with newbie chat -
gotenks918 - 10.03.2010
Indeed, everyone goes through a learning stage and only saying the method on how to actually create his idea seems a little useless when saying it to someone who is still learning to script.
Re: Need help with newbie chat -
Kyosaur - 10.03.2010
im sort of busy, so i cant give a full example, can only tell you what you need
.
GetTickCount to check the time (check the time fs in your filterscript folder, it shows its use.)
and
A max player array to store each players tick values (should have 1 at the begging of the command, and a second one after it).
sorry for not having enough time to go make one
.
EDIT if you still dont get it/no one else will help, pm me and i'll send it once im done.
Re: Need help with newbie chat -
Finn - 10.03.2010
Why
GetTickCount()? The ticks returned by that function are
not equal to miliseconds, it fully depends on the speed of the host computer.
I'd just use
gettime(), it returns seconds so it's easier to handle aswell as you don't need to deal with miliseconds.
Re: Need help with newbie chat -
Razvann - 10.03.2010
Very simple, try:
At the top:
pawn Код:
new PlayerNewbie[MAX_PLAYERS];
OnPlayerConnect
pawn Код:
PlayerNewbie[playerid] = 0;
At the publics:
pawn Код:
public ResetN(playerid)
{
PlayerNewbie[playerid] = 0;
}
At the command:
pawn Код:
if(PlayerNewbie[playerid] == -1)
{
SendClientMessage(playerid,COLOR,"You can only send a message once 50 seconds !");
return 1;
}
And under the SendClientMessage:
pawn Код:
SetTimerEx("ResetN", 50000, 0, "d", playerid);
PlayerNewbie[playerid] = -1;
Re: Need help with newbie chat -
Finn - 10.03.2010
Top of the script:
pawn Код:
new newbTime[MAX_PLAYERS];
OnPlayerConnect: (not really a must, but it's good to reset the player arrays in this callback)
In the command:
pawn Код:
new time = gettime();
if((time - newbTime[playerid]) < 50) return SendClientMessage(playerid, COLOR_HERE, "You have to wait 50 seconds blah blah...");
newbTime[playerid] = time;
// Rest of the command.
Timer is not needed.
Re: Need help with newbie chat -
Kyosaur - 10.03.2010
Quote:
Originally Posted by Finn
Why GetTickCount()? The ticks returned by that function are not equal to miliseconds, it fully depends on the speed of the host computer.
I'd just use gettime(), it returns seconds so it's easier to handle aswell as you don't need to deal with miliseconds.
|
Im 95% sure you are wrong regarding it not equaling milliseconds. It should equal the up time of the server in miliseconds. I highly doubt computer speed has any play what so ever (it does make a little sense to me though, hence the 95).
Either way works, i guess it all depends on your preference.
Quote:
Originally Posted by Finn
Top of the script:
pawn Код:
new newbTime[MAX_PLAYERS];
OnPlayerConnect: (not really a must, but it's good to reset the player arrays in this callback)
In the command:
pawn Код:
new time = gettime();
if((time - newbTime[playerid]) < 50) return SendClientMessage(playerid, COLOR_HERE, "You have to wait 50 seconds blah blah...");
newbTime[playerid] = time;
// Rest of the command.
Timer is not needed.
|
That will never work. One reason why i do not use gettime is because it requires 3 variable declarations (hours, mins, seconds). If you dont put those three parameters in the function, which you did not, it will return the number of seconds since 1 January 1970.
Re: Need help with newbie chat -
Finn - 10.03.2010
Quote:
Originally Posted by Kyosaur!!
That will never work. One reason why i do not use gettime is because it requires 3 variable declarations (hours, mins, seconds). If you dont put those three parameters in the function, which you did not, it will return the number of seconds since 1 January 1970.
|
1. It works.
2. It doesn't need those parameters.
3. Yes, it obviously needs some date to get the seconds from and it doesn't make any difference whether it's from the start of the server or 1. January 1970, as we're just comparing the time difference between those 2 times.
100 - 50 is 50 just like 978050 - 978000.