#include "a_samp"
#include "zcmd"
#define COUNTRANGE 20
forward Count1(playerid);
forward Count2(playerid);
forward Count3(playerid);
forward Count4(playerid);
forward Count5(playerid);
forward Count6(playerid);
forward Count7(playerid);
forward Count8(playerid);
forward Count9(playerid);
forward Count10(playerid);
public OnFilterScriptInit()
{
return 1;
}
CMD:count(playerid,params[])
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
SetTimer("Count1",1000,false);
if IsPlayerInRangeOfPoint(playerid, COUNTRANGE, x, y, z) *then SetTimer("Count1",1000,false);
return 1;
}
public Count1(playerid)
{
GameTextForPlayer(playerid,"~g~10",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count2",1000,false);
return 1;
}
public Count2(playerid)
{
GameTextForPlayer(playerid,"~g~9",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count3",1000,false);
return 1;
}
public Count3(playerid)
{
GameTextForPlayer(playerid,"~g~8",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count4",1000,false);
return 1;
}
public Count4(playerid)
{
GameTextForPlayer(playerid,"~g~7",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count5",1000,false);
return 1;
}
public Count5(playerid)
{
GameTextForPlayer(playerid,"~g~6",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count6",1000,false);
return 1;
}
public Count6(playerid)
{
GameTextForPlayer(playerid,"~g~5",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count7",1000,false);
return 1;
}
public Count7(playerid)
{
GameTextForPlayer(playerid,"~g~4",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count8",1000,false);
return 1;
}
public Count8(playerid)
{
GameTextForPlayer(playerid,"~g~3",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count9",1000,false);
return 1;
}
public Count9(playerid)
{
GameTextForPlayer(playerid,"~g~2",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
SetTimer("Count10",1000,false);
return 1;
}
public Count10(playerid)
{
GameTextForPlayer(playerid,"~g~1",1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
return 1;
}
Public Count(playerid, seconds)
{
String = seconds;
GameTextForPlayer("blabla, string");
seconds = seconds-1;
If seconds > 0 Then
{
SetTimerEx("Count",1000,True, "ii", playerid, seconds);
}
Return 1;
}
|
Make 1 callback.
Код:
Public Count(playerid, seconds)
{
String = seconds;
GameTextForPlayer("blabla, string");
seconds = seconds-1;
If seconds > 0 Then
{
SetTimerEx("Count",1000,True, "ii", playerid, seconds);
}
Return 1;
}
I hope you understand what I mean with this and please dont copy and paste this onto your script because it wont work. But learn to script practically. You dont need a "count" for every second, you can use SetTimerEx and take the seconds variable into the callback. https://sampwiki.blast.hk/wiki/SetTimerEx |
|
thats not the helping,i know how to set timer but tell me how to set timer for the entered time.
|
forward Count1(playerid, seconds);
CMD:count(playerid,params[])
{
new iSec, Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
iSec = StrVal(params);
SetTimerEx("Count1",1000,false, "ii", playerid, iSec);
return 1;
}
public Count1(playerid, seconds)
{
new string[128];
format(string, sizeof(string), "~g~%d", seconds);
GameTextForPlayer(playerid,string,1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
seconds = seconds -1;
if seconds > -1 then
{
SetTimerEx("Count1",1000,false, "ii", playerid, seconds);
}
return 1;
}
forward Count1(playerid, seconds);
CMD:count(playerid,params[])
{
new iSec, Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
iSec = StrVal(params);
SetTimerEx("Count1",1000,false, "ii", playerid, iSec);
return 1;
}
public Count1(playerid, seconds)
{
new string[128];
format(string, sizeof(string), "~g~%d", seconds);
GameTextForPlayer(playerid,string,1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
seconds = seconds -1;
if seconds > -1 *then
{
SetTimerEx("Count1",1000,false, "ii", playerid, seconds);
}
return 1;
}
|
Forgot?
Код:
forward Count1(playerid, seconds);
CMD:count(playerid,params[])
{
new iSec, Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
iSec = StrVal(params);
SetTimerEx("Count1",1000,false, "ii", playerid, iSec);
return 1;
}
public Count1(playerid, seconds)
{
new string[128];
format(string, sizeof(string), "~g~%d", seconds);
GameTextForPlayer(playerid,string,1000,3);
PlayerPlaySound(playerid, 1056,0,0,0);
seconds = seconds -1;
if seconds > -1 *then
{
SetTimerEx("Count1",1000,false, "ii", playerid, seconds);
}
return 1;
}
|
|
#include <zcmd>
#include <sscanf2> new Count; new CountTimer; CMD:count(playerid,params[]) { new seconds; if(sscanf(params,"i",seconds)) return SendClientMessage(playerid,-1,"Usage: /count [Seconds]"); Count=seconds; CountTimer = SetTimer("Counting",1000,true); return 1; } forward Counting(); public Counting() { Count --; if(Count == 0){ KillTimer(CountTimer); GameTextForAll("GO GO GO",1000,3); }else{ new string[20]; format(string,sizeof(string),"%d",Count); GameTextForAll(string,1000,3); } } |