16.06.2013, 21:46
Entгo, esse ai й o meu time attack da big ear, eu queria colocar um cronometro em textdraw ou algo parecido nele saco? tipo, depois do go go go, o tempo do time attack comeзa a contar, e esse tempo aparecer na tela
no cantinho da tela apareceria... 1, 2, 3, 4, atй terminar, eu ja vi isso em alguns svs, mas nao achei no ****** nem no search do forum '-'
help-me '-'
no cantinho da tela apareceria... 1, 2, 3, 4, atй terminar, eu ja vi isso em alguns svs, mas nao achei no ****** nem no search do forum '-'
help-me '-'
Код:
#include <a_samp> #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define COLOR_RED 0xAA3333AA #define COLOR_YELLOW 0xFFFF00AA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_LAVENDER 0xFF00FFAA #define COLOR_BLUE 0x0000BBAA #define COLOR_LIGHTBLUE 0x33CCFFAA #define COLOR_LIGHTBLUEA 0xB5EAFCAA #define COLOR_ORANGE 0xFF9900AA #define COLOR_TEAL 0x3BAAC2AA #include "../include/gl_common.inc" #define blue 0x375FFFFF #define ADMINFS_MESSAGE_COLOR 0xFF444499 #define PM_INCOMING_COLOR 0xFFFF22AA #define PM_OUTGOING_COLOR 0xFFCC2299 static iPlayerChatTime[MAX_PLAYERS]; static szPlayerChatMsg[MAX_PLAYERS][128]; //------------------------------------------------ //------------------------------------------------ forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z); forward CheckpointUpdate(); forward GPRaceCountdown(); forward GPTimer(); forward SaveTimes(); forward LoadTimes(); forward UpdateList(playerid,TimeRec); new Mototime[MAX_PLAYERS] =0; new Motocountdown[MAX_PLAYERS] =-1; new MotoGP[MAX_PLAYERS] = 0; new MotoGate[MAX_PLAYERS]=0; #define MAX_POINTS 1 #define MAX_RACE_POINTS 17 #define TT_START 0 enum kinfo{ Driver[24], Time } new KartHS[5][kinfo]; new playerCheckpoint[MAX_PLAYERS]; new Float:checkpoints[MAX_POINTS][23] = { {-302.1711,1508.3451,75.3594} }; new Float:racecheckpoints[MAX_RACE_POINTS][18] = { {-305.4507,1395.2365,72.3118}, { -375.1031,1461.8661,62.1423}, { -328.6879,1316.2310,52.4871}, { -447.1574,1500.4052,34.9547}, { -399.9567,1750.0654,42.6130}, { -409.4537,1918.7510,57.7848}, { -439.1856,1759.7423,72.0444}, { -388.9103,2080.4001,61.1164}, { -532.2165,1990.8622,60.3906}, { -384.1641,2075.6667,60.9181}, { -439.3697,1761.9298,72.0275}, { -418.0215,1917.2354,57.4656}, { -443.9293,1630.9391,35.6589}, { -324.8012,1316.9939,52.8978}, { -370.5130,1462.3467,62.6581}, { -308.6009,1395.1691,72.2705}, { -301.6882,1501.4779,75.5935} }; new checkpointType[MAX_POINTS] = { TT_START }; public OnFilterScriptInit() { SetTimer("CheckpointUpdate",1000,1); SetTimer("GPRaceCountdown",1000,1); SetTimer("GPTimer",1000,1); for(new t=0; t<5; t++) { strmid(KartHS[t][Driver], "None", 0, strlen("None"), 24); KartHS[t][Time]=100000; } if(!fexist("Drift Times.cfg")) SaveTimes(); LoadTimes(); return 1; } public SaveTimes() { print("[race] Drift Times Saved."); new File: hFile = fopen("Drift Times.cfg", io_write); if (hFile) { for(new t= 0; t<5; t++) { new var[32]; format(var, 32, "%s\n",KartHS[t][Driver]);fwrite(hFile, var); format(var, 32, "%d\n",KartHS[t][Time]);fwrite(hFile, var); } } fclose(hFile); return 1; } public LoadTimes() { print("[race] Drift Times Loaded."); new File: file = fopen("Drift Times.cfg", io_read); if (file) { new valtmp[128]; for(new t=0; t<5; t++) { fread(file, valtmp);strmid(KartHS[t][Driver], valtmp, 0, strlen(valtmp)-1, 128);DelPrint(valtmp); fread(file, valtmp);KartHS[t][Time] = strval(valtmp);DelPrint(valtmp); } } return 1; } public OnPlayerDisconnect(playerid,reason) { #pragma unused reason iPlayerChatTime[playerid] = 0; szPlayerChatMsg[playerid] = ""; MotoGP[playerid] =0; Mototime[playerid] =0; return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/Race", cmdtext, true, 10) == 0) { new carid; carid = GetPlayerVehicleID(playerid); if(GetVehicleModel(carid) != 562) return SendClientMessage(playerid, 0xB5EAFCAA, "{FF9900}Vocк precisa de um {AFAFAF}Elegy!"); if(getCheckpointType(playerid)!=TT_START) { SendClientMessage(playerid,COLOR_RED,"{F60000}[ERRO] {AFAFAF}Vocк deve estar no local de partida."); return 1; } RemoveVehicleComponent(carid, 1010); SetPlayerVirtualWorld(playerid, 25); SetVehicleVirtualWorld(carid, 25); SendClientMessage(playerid, COLOR_WHITE,"{AFAFAF}[INFO] {FFFF00}Comeзando, boa sorte!"); SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid,0); Motocountdown[playerid] = 6; SetPlayerRaceCheckpoint(playerid,0,racecheckpoints[0][0],racecheckpoints[0][1],racecheckpoints[0][2],racecheckpoints[1][0],racecheckpoints[1][1],racecheckpoints[1][2],10); DisablePlayerCheckpoint(playerid); return 1; } if (strcmp("/TRace", cmdtext, true, 10) == 0) { new kstring[255]; new carid; carid = GetPlayerVehicleID(playerid); AddVehicleComponent(carid, 1010); SendClientMessage(playerid,0xFFFF00AA,"Top 5 tempos:"); for(new z=0; z<5; z++) { new sec = KartHS[z][Time]%60; new mins = (KartHS[z][Time]/60)%60; if (strcmp("None",KartHS[z][Driver], true, 10) == 0) { if(z==0) SendClientMessage(playerid,0xAFAFAFAA,"- Nenhum tempo gravado ainda -"); if(z>0) SendClientMessage(playerid,0xAFAFAFAA,"- Final da lista de tempo -"); return 1; } if(strcmp("None",KartHS[z][Driver], true,10) != 0) { if(sec > 9) {format(kstring,sizeof(kstring),"%d. %s - %d:%d",z+1,KartHS[z][Driver],mins,sec);} if(sec < 9) {format(kstring,sizeof(kstring),"%d. %s - %d:0%d",z+1,KartHS[z][Driver],mins,sec);} SendClientMessage(playerid,COLOR_GREY,kstring); } } return 1; } return 0; } public OnPlayerEnterRaceCheckpoint(playerid) { new sec = Mototime[playerid]%60; new mins = (Mototime[playerid]/60)%60; if(MotoGP[playerid] == 1) { MotoGate[playerid]++; new one = MAX_RACE_POINTS-1; new two = MAX_RACE_POINTS; if(MotoGate[playerid] < one) { DisablePlayerRaceCheckpoint(playerid); SetPlayerRaceCheckpoint(playerid,0,racecheckpoints[MotoGate[playerid]][0],racecheckpoints[MotoGate[playerid]][1],racecheckpoints[MotoGate[playerid]][2],racecheckpoints[MotoGate[playerid]+1][0],racecheckpoints[MotoGate[playerid]+1][1],racecheckpoints[MotoGate[playerid]+1][2],10); } if(MotoGate[playerid] == one) { DisablePlayerRaceCheckpoint(playerid); SetPlayerRaceCheckpoint(playerid,1,racecheckpoints[MotoGate[playerid]][0],racecheckpoints[MotoGate[playerid]][1],racecheckpoints[MotoGate[playerid]][2],racecheckpoints[0][0],racecheckpoints[0][1],racecheckpoints[0][2],10); } if(MotoGate[playerid] == two) { new TimeRec; new Timestr[255]; new driver[24]; GetPlayerName(playerid,driver,sizeof(driver)); format(Timestr,sizeof(Timestr),"{FFFF00}%s {FFFFFF}terminou o Time Attack em {FFFF00}%d {FFFFFF}Minutos, {FFFF00}%d{FFFFFF} segundos!",driver,mins,sec); SendClientMessageToAll(0x375FFFFF,Timestr); new carid; carid = GetPlayerVehicleID(playerid); SetPlayerVirtualWorld(playerid, 0); SetVehicleVirtualWorld(carid, 0); GivePlayerMoney(playerid,4000); AddVehicleComponent(carid, 1010); SetPlayerScore(playerid,GetPlayerScore(playerid)+10); SendClientMessage(playerid,COLOR_YELLOW,"{FFFFFF}Vocк pode ver os {FFFF00}5 Melhores Tempos{FFFFFF} usando {FFFF00}/TRace{FFFFFF}."); printf(Timestr); TimeRec=Mototime[playerid]; MotoGP[playerid] = 0; MotoGate[playerid] = 0; DisablePlayerRaceCheckpoint(playerid); Mototime[playerid]=0; UpdateList(playerid,TimeRec); } } return 1; } public OnPlayerEnterCheckpoint(playerid) { if(getCheckpointType(playerid)==TT_START) { if(IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid,blue,"{FFFFFF}Digite {FFFF00}/Race {FFFFFF}para Iniciar o {FFFF00}Time Attack{FFFFFF}."); return 1; } else { SendClientMessage(playerid,COLOR_RED,"{FFFFFF}Erro! Vocк precisa estar em um {FFFF00}Elegy {FFFFFF}para iniciar esse Time Attack."); } } return 1; } stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } return 0; } public UpdateList(playerid, TimeRec) { new driver[24]; GetPlayerName(playerid,driver,sizeof(driver)); if(KartHS[0][Time] > TimeRec) { KartHS[4][Time] = KartHS[3][Time]; strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24); KartHS[3][Time] = KartHS[2][Time]; strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24); KartHS[2][Time] = KartHS[1][Time]; strmid(KartHS[2][Driver],KartHS[1][Driver],0,sizeof(driver),24); KartHS[1][Time] = KartHS[0][Time]; strmid(KartHS[1][Driver],KartHS[0][Driver],0,sizeof(driver),24); KartHS[0][Time] = TimeRec; strmid(KartHS[0][Driver],driver,0,sizeof(driver),24); SendClientMessage(playerid,COLOR_GREY,"{FFFFFF}Seu tempo foi o {FFFF00}1є {FFFFFF}Classificado!"); } else if(KartHS[1][Time] > TimeRec) { KartHS[4][Time] = KartHS[3][Time]; strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24); KartHS[3][Time] = KartHS[2][Time]; strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24); KartHS[2][Time] = KartHS[1][Time]; strmid(KartHS[2][Driver],KartHS[1][Driver],0,sizeof(driver),24); KartHS[1][Time] = TimeRec; strmid(KartHS[1][Driver],driver,0,sizeof(driver),24); SendClientMessage(playerid,COLOR_GREY,"Seu tempo foi 2є Classificado!"); } else if(KartHS[2][Time] > TimeRec) { KartHS[4][Time] = KartHS[3][Time]; strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24); KartHS[3][Time] = KartHS[2][Time]; strmid(KartHS[3][Driver],KartHS[2][Driver],0,sizeof(driver),24); KartHS[2][Time] = TimeRec; strmid(KartHS[2][Driver],driver,0,sizeof(driver),24); SendClientMessage(playerid,COLOR_GREY,"Seu tempo foi 3є Classificado!"); } else if(KartHS[3][Time] > TimeRec) { KartHS[4][Time] = KartHS[3][Time]; strmid(KartHS[4][Driver],KartHS[3][Driver],0,sizeof(driver),24); KartHS[3][Time] = TimeRec; strmid(KartHS[3][Driver],driver,0,sizeof(driver),24); SendClientMessage(playerid,COLOR_GREY,"Seu tempo foi 4є Classificado!"); } else if(KartHS[4][Time] > TimeRec) { KartHS[4][Time] = TimeRec; strmid(KartHS[4][Driver],driver,0,sizeof(driver),24); SendClientMessage(playerid,COLOR_GREY,"Seu tempo foi 5є Classificado!"); } SaveTimes(); LoadTimes(); return 1; } public CheckpointUpdate() { for(new i; i<MAX_PLAYERS; i++) { if(MotoGP[i] == 0) { for(new j=0; j < 1; j++) { if(PlayerToPoint(25,i,checkpoints[j][0],checkpoints[j][1],checkpoints[j][2])) { if(playerCheckpoint[i]!=j) { DisablePlayerCheckpoint(i); SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],5); playerCheckpoint[i] = j; } } else { if(playerCheckpoint[i]==j) { DisablePlayerCheckpoint(i); playerCheckpoint[i] = 999; } } } } } } stock getCheckpointType(playerID) { if(playerCheckpoint[playerID] != 999) return checkpointType[playerCheckpoint[playerID]]; else return -1; } public GPRaceCountdown() { for(new x=0; x<MAX_PLAYERS; x++) { if(Motocountdown[x] > 0) { new time[3]; Motocountdown[x]--; format(time,sizeof(time),"%d",Motocountdown[x]); PlayerPlaySound(x, 1056, 0, 0, 0); GameTextForPlayer(x,time,1200,3); } if(Motocountdown[x] == 0) { GameTextForPlayer(x,"GO!",1200,3); PlayerPlaySound(x, 1057, 0, 0, 0); TogglePlayerControllable(x,1); Motocountdown[x]--; Mototime[x]=0; MotoGP[x]=1; } } } public GPTimer() { for(new i=0; i < MAX_PLAYERS; i++) { if(MotoGP[i] == 1) Mototime[i]++; } } stock DelPrint(string1[]) { strmid(string1, string1, 0, strlen(string1)-1, 255); printf("%s", string1); return 1; } public OnPlayerConnect(playerid) { MotoGP[playerid] = 0; MotoGate[playerid] = 0; DisablePlayerRaceCheckpoint(playerid); Mototime[playerid]=0; return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if (MotoGP[playerid] == 1 && (newstate == 1 && oldstate == 2)) { MotoGP[playerid] = 0; MotoGate[playerid] = 0; DisablePlayerRaceCheckpoint(playerid); Mototime[playerid]=0; } return 1; } public OnPlayerDeath(playerid, killerid, reason) { MotoGP[playerid] = 0; MotoGate[playerid] = 0; DisablePlayerRaceCheckpoint(playerid); Mototime[playerid]=0; return 1; }