Dexter1906 0 Odesláno: 19. Únor, 2014 Share Odesláno: 19. Únor, 2014 Dobrý deň, vedel by niekto o nejakej funkcii na odpočet, proste, že príde admin, napíše napríklad /odpocet 60 Event čiže proste nejaký príkaz čas v sekundách a dôvod. Pomohli by ste mi niekto prosím? Link to comment Share on other sites More sharing options...
0 kell94_cz 7 Odesláno: 19. Únor, 2014 Share Odesláno: 19. Únor, 2014 Nahoru mezi new: new KOdpocet; Mezi forwardy: forward EOdpocet(); Do OnPlayerCommandText: dcmd(odpocet,7,cmdtext); Někam mimo publicy: dcmd_odpocet(playerid, params[]) { new string[128],cas,duvod[50]; if(sscanf(params,"iz",cas,duvod)) return SendClientMessage(playerid,-1,"Použití: /odpocet [0 - 60] [ DŮVOD ]"); if(cas < 0 || cas > 60) return SendClientMessage(playerid,-1,"Rozmezí [0 - 60]"); if(KOdpocet > 0) return SendClientMessage(playerid,-1,"Odpočet již probíhá."); format(string,sizeof(string),"%s spustil odpočet na %d sekund.",PlayerName(playerid),cas); SendClientMessageToAll(-1,string); KOdpocet = cas; SetTimer("EOdpocet",1000,false); return true; } Někam dolů: public EOdpocet() { new string[128]; if(KOdpocet > 0) { format(string,sizeof(string),"~g~%d",KOdpocet); GameTextForAll(string,1000,4); KOdpocet--; SetTimer("EOdpocet",1000,false); }else{ GameTextForAll("~r~!START!",2000,4); } } Pokud nemáš stock PlayerName tak někam dolů si dej tohle pokud tam teda nemáš jiný stock na zjišťování nicku: stock PlayerName(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); return name; } Pokud nemáš stock sscanf tak někam dolů: stock sscanf(string[], format[], {Float,_}:...) { #if defined isnull if (isnull(string)) #else if (string[0] == 0 || (string[0] == 1 && string[1] == 0)) #endif { return format[0]; } #pragma tabsize 4 new formatPos = 0, stringPos = 0, paramPos = 2, paramCount = numargs(), delim = ' '; while (string[stringPos] && string[stringPos] <= ' ') { stringPos++; } while (paramPos < paramCount && string[stringPos]) { switch (format[formatPos++]) { case '\0': { return 0; } case 'i', 'd': { new neg = 1, num = 0, ch = string[stringPos]; if (ch == '-') { neg = -1; ch = string[++stringPos]; } do { stringPos++; if ('0' <= ch <= '9') { num = (num * 10) + (ch - '0'); } else { return -1; } } while ((ch = string[stringPos]) > ' ' && ch != delim); setarg(paramPos, 0, num * neg); } case 'h', 'x': { new num = 0, ch = string[stringPos]; do { stringPos++; switch (ch) { case 'x', 'X': { num = 0; continue; } case '0' .. '9': { num = (num << 4) | (ch - '0'); } case 'a' .. 'f': { num = (num << 4) | (ch - ('a' - 10)); } case 'A' .. 'F': { num = (num << 4) | (ch - ('A' - 10)); } default: { return -1; } } } while ((ch = string[stringPos]) > ' ' && ch != delim); setarg(paramPos, 0, num); } case 'c': { setarg(paramPos, 0, string[stringPos++]); } case 'f': { new changestr[16], changepos = 0, strpos = stringPos; while(changepos < 16 && string[strpos] && string[strpos] != delim) { changestr[changepos++] = string[strpos++]; } changestr[changepos] = '\0'; setarg(paramPos,0,_:floatstr(changestr)); } case 'p': { delim = format[formatPos++]; continue; } case '\'': { new end = formatPos - 1, ch; while ((ch = format[++end]) && ch != '\'') {} if (!ch) { return -1; } format[end] = '\0'; if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1) { if (format[end + 1]) { return -1; } return 0; } format[end] = '\''; stringPos = ch + (end - formatPos); formatPos = end + 1; } case 'u': { new end = stringPos - 1, id = 0, bool:num = true, ch; while ((ch = string[++end]) && ch != delim) { if (num) { if ('0' <= ch <= '9') { id = (id * 10) + (ch - '0'); } else { num = false; } } } if (num && IsPlayerConnected(id)) { setarg(paramPos, 0, id); } else { #if !defined foreach #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2)) #define __SSCANF_FOREACH__ #endif string[end] = '\0'; num = false; new name[MAX_PLAYER_NAME]; id = end - stringPos; foreach (Player, playerid) { GetPlayerName(playerid, name, sizeof (name)); if (!strcmp(name, string[stringPos], true, id)) { setarg(paramPos, 0, playerid); num = true; break; } } if (!num) { setarg(paramPos, 0, INVALID_PLAYER_ID); } string[end] = ch; #if defined __SSCANF_FOREACH__ #undef foreach #undef __SSCANF_FOREACH__ #endif } stringPos = end; } case 's', 'z': { new i = 0, ch; if (format[formatPos]) { while ((ch = string[stringPos++]) && ch != delim) { setarg(paramPos, i++, ch); } if (!i) { return -1; } } else { while ((ch = string[stringPos++])) { setarg(paramPos, i++, ch); } } stringPos--; setarg(paramPos, i, '\0'); } default: { continue; } } while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ') { stringPos++; } while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' ')) { stringPos++; } paramPos++; } do { if ((delim = format[formatPos++]) > ' ') { if (delim == '\'') { while ((delim = format[formatPos++]) && delim != '\'') {} } else if (delim != 'z') { return delim; } } } while (delim > ' '); return 0; } Definici pro dcmd doufám máš a pokud ne tak tady je: #define dcmd(%1,%2,%3) if((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 Link to comment Share on other sites More sharing options...
0 Mattsy 29 Odesláno: 20. Únor, 2014 Share Odesláno: 20. Únor, 2014 Prečo tak zložito? nebolo by jednoduchšie nastaviť settimer na opakovanie a potom použiť KillTimer ak sa KOdpocet == 0 ? + potom treba nastaviť hodnotu -1 a štart by som vypisoval iba ak sa rovná 0 JO a ešte jedna vec..on chcel aj dôvod čo tam nemáš A ešte: AOdpocet--; Snáď KOdpocet nie? Link to comment Share on other sites More sharing options...
0 kell94_cz 7 Odesláno: 20. Únor, 2014 Share Odesláno: 20. Únor, 2014 Vzal jsem to z mého starého FS co mám u sebe už se tomu moc nevěnuji tak jsem rád že jsem mu aspoň nějak takhle poradil a ten důvod ten jsem přehlédl to se omlouvám až budu doma tak to upravím ještě aby tam byl i ten důvod a díky za radu a za upozornění na chybu nekopíroval jsem to z FS ale psal jsem to tak jsem se přehmátl tak to taky pak opravím. Link to comment Share on other sites More sharing options...
0 Dexter1906 0 Odesláno: 20. Únor, 2014 Author Share Odesláno: 20. Únor, 2014 Dík zatial za pomoc ale ešte aj ten dôvod by som chcel. Link to comment Share on other sites More sharing options...
0 kell94_cz 7 Odesláno: 20. Únor, 2014 Share Odesláno: 20. Únor, 2014 Už jsem ti to upravil. Link to comment Share on other sites More sharing options...
0 Dexter1906 0 Odesláno: 20. Únor, 2014 Author Share Odesláno: 20. Únor, 2014 Dalo by sa spraviť niečo na štýl tohto? dcmd_jetpack(playerid,params[]) { new id = strval(params); if(Player[playerid][AdminLevel]==0) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Niesi Administrátor !"); else if(Player[playerid][AdminLevel]<=3) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Na použitie tohto príkazu potrebuješ Admin Level 4 !"); else if(!strlen(params) || !strlen(params[chrfind(' ',params)+1])) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Použi: /jetpack [ID]"); else if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Hráč so zadaným ID nie je na serveri !"); else return SetPlayerSpecialAction(id, 2); Proste, nie na ID ani tak, ale proste tým štýlom funkcií aké sú tam. Pretože mám tam funkcie na získanie mien, lenže v pawne som začiatočník tak netuším ako to mám správne použiť.Na získavanie mien tam je tuším funkcia: public OnPlayerConnect(playerid) { new Name[24]; GetPlayerName(playerid,Name,24); if(!strcmp(Name, "SERVER", false)) { SendClientMessage(playerid,0xC0C0C0FF,"Invalid name."); return Kick(playerid); } if(playerid >= MAX_PLAYERS_EX) { SendClientMessage(playerid,0xC0C0C0FF,"Server is full."); return Kick(playerid); } if(!IsPlayerNPC(playerid)) { for(new i=0; i<=Server[ConP]; i++) { if(IsPlayerConnected(i)) { if(!IsPlayerNPC(i)) { ShowPlayerNameTagForPlayer(playerid, i, true); } } } Pomohol by mi niekto? Link to comment Share on other sites More sharing options...
0 PiratesOfSamp 1 Odesláno: 20. Únor, 2014 Share Odesláno: 20. Únor, 2014 kell94_cz --- Pekne vysvetlene Link to comment Share on other sites More sharing options...
0 Dexter1906 0 Odesláno: 21. Únor, 2014 Author Share Odesláno: 21. Únor, 2014 Zatiaľ dík za pomoc, skúsil som si to prerobiť na svoj mód, ako som už písal som začiatočník, takže mi to vyhádzalo 2 erroy 204 a v hre mi premenná nefungovala čiže mi rovno spúšťalo štart. Errory: warning 204: symbol is assigned a value that is never used: "id" warning 204: symbol is assigned a value that is never used: "duvod" Môj dcmd_odpocet //------------------------------------------------------------ dcmd_odpocet(playerid, params[]) { new string[128],cas,duvod[50]; new id = strval(params); if(Player[playerid][AdminLevel]==0) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Nie si Administrátor !"); else if(Player[playerid][AdminLevel]<=1) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Na použitie tohto príkazu potrebuješ Admin Level 2 !"); else if(!strlen(params) || !strlen(params[chrfind(' ',params)+1])) return SendClientMessage(playerid,COLOR_WARNING,"[ ! ] {FFFFFF}Použi: /odpocet [0 - 60] [DÔVOD]"); if(cas < 0 || cas > 60) return SendClientMessage(playerid,-1,"Rozmedzie odpočtu je [0 - 60] sekúnd."); if(KOdpocet > 0) return SendClientMessage(playerid,-1,"Odpočet už prebieha."); format(string,256,"Administrátor %s spustil odpočet na %d sekúnd[ Dôvod: %s ]",PlayerName(playerid),cas,params[chrfind(' ',params)+1]); SendClientMessageToAll(-1,string); KOdpocet = cas; SetTimer("EOdpocet",1000,false); return true; } //------------------------------------------------------------ Síce mi to scompilovalo, ale ako som už písal, v hre mi akosi nefunguje premenná čas, čiže mi to rovno spúšťa štart a pri Administrátor xxxx spustil odpočet na X sekúnd mi rovno píše 0 a dôvod funguje. Poopravil by ma prosím niekto? Ako ten kód upraviť? Pomohol by mi niekto? Link to comment Share on other sites More sharing options...
0 Mattsy 29 Odesláno: 21. Únor, 2014 Share Odesláno: 21. Únor, 2014 Nie su to errory ale warningy a znacia len ze tie dve prwmenny nie su nikde poizite...staci si to prelozit :)nie je to nic vazne..mne takychto warnov vyhadzuje v gm momentalne 12 ...viac ti momentapne neporadim pretoze som na mobile...vecer ked tak Link to comment Share on other sites More sharing options...
0 Tanga 131 Odesláno: 21. Únor, 2014 Share Odesláno: 21. Únor, 2014 Ja používam zcmd, môj príkaz na odpočet by vyzeral jednoduchšie a dá sa lahko rozšíriť o nové veci: #include <a_samp> #include <zcmd> #define FILTERSCRIPT new odpocet = -1; forward Casovac_Sekunda(); public OnFilterScriptInit() { SetTimer("Casovac_Sekunda", 1000, 1); return 1; } public Casovac_Sekunda() { if (odpocet != -1) { if (odpocet-- == 1) GameTextForAll("START", 1000, 3); else if (odpocet > 0) { new str[16]; valstr(str, odpocet); GameTextForAll(str, 1000, 3); } } } command(odpocet, playerid, params[]) { if (isnull(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Použitie: /odpocet casvsekundach"); odpocet = strval(params); return 1; } Link to comment Share on other sites More sharing options...
0 Dexter1906 0 Odesláno: 21. Únor, 2014 Author Share Odesláno: 21. Únor, 2014 Ja mám celý mód v dcmd, tak nechcem to zrazu meniť. Nevieš ako to opraviť tú premennú aby fungovala? Lebo sekundy neidú, proste to hneď odštartuje. Link to comment Share on other sites More sharing options...
0 Tanga 131 Odesláno: 21. Únor, 2014 Share Odesláno: 21. Únor, 2014 Tak si daj môj kód do dcmd. Link to comment Share on other sites More sharing options...
0 Dexter1906 0 Odesláno: 21. Únor, 2014 Author Share Odesláno: 21. Únor, 2014 A vedel by si ho upraviť podľa mojich levelov? Prosím, lebo mne to trvá dlho a väčšinou to ešte spravím aj zle Link to comment Share on other sites More sharing options...
Dotaz
Dexter1906 0
Dobrý deň, vedel by niekto o nejakej funkcii na odpočet, proste, že príde admin, napíše napríklad /odpocet 60 Event čiže proste nejaký príkaz čas v sekundách a dôvod.
Pomohli by ste mi niekto prosím?
Link to comment
Share on other sites
13 odpovědí na tuto otázku
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now