Guyy 14 Odesláno: 16. Červenec, 2018 Share Odesláno: 16. Červenec, 2018 (upraveno) Po dlhšej dobe som si šiel zasa niečo vytvoriť, ale mám problém s sscanf-om.. Keď ho pridám ako include, tak mi to skompiluje ale ked použijem príkaz kde je sscanf, kód sa dostane po sscanf a spadne server. Keď ho pridám ako stock, prvý krát napíše "Unknown command" a druhý krát už spraví čo má.. Ďakujem za pomoc Kódy: Mód: #include <a_samp> #include <sscanf> #include <sampp> #include <izcmd> #include <YSI_Coding\y_va> #define ver "0.2" #define IZCMD_ENABLE_CASE_SENSITIVITY public OnGameModeInit() { SetGameModeText("Test Gamemode "ver""); return 1; } public OnPlayerConnect(playerid) { ToggleHUDComponentForPlayer(playerid, HUD_COMPONENT_MONEY, false); return 1; } CMD:test(playerid, params[]) { new num; if(sscanf(params, "i", num)) return SendClientMessage(playerid, -1, "{FF0000}[ ! ] {FFFFFF}Test: /test [num]"); va_SendClientMessage(playerid, -1, "{FF0000}[ ! ] {FFFFFF}Num = %i.", num); return 1; } sscanf include: #include <a_samp> 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; for(new i; i < MAX_PLAYERS; i++) { GetPlayerName(i, name, sizeof (name)); if (!strcmp(name, string[stringPos], true, id)) { setarg(paramPos, 0, i); 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; } Edited 16. Červenec, 2018 by Guyy Link to comment Share on other sites More sharing options...
Quiter 99 Odesláno: 16. Červenec, 2018 Share Odesláno: 16. Červenec, 2018 (upraveno) Skús stiahnúť iný sscanf - možno je poškodeny. Prečo nepoužiješ plugin? Funguje príkaz normálne keď dáš preš sscanf? Edited 16. Červenec, 2018 by Quiter Link to comment Share on other sites More sharing options...
Tanga 131 Odesláno: 16. Červenec, 2018 Share Odesláno: 16. Červenec, 2018 před 3 hodinami, Quiter said: Skús stiahnúť iný sscanf - možno je poškodeny. Prečo nepoužiješ plugin? Funguje príkaz normálne keď dáš preš sscanf? Súhlasím, v praxi som videl sscanf iba ako plugin. Tento plugin tiež obsahuje .inc súbor (ktorý musíš použiť), ale nenachádza sa v ňom žiadny kód (iba prepojenie s pluginom). Link to comment Share on other sites More sharing options...
Guyy 14 Odesláno: 16. Červenec, 2018 Author Share Odesláno: 16. Červenec, 2018 No tak skúsil som nájsť ten include (bez pluginu) ale nenašiel som, jedine čo som našiel je v QWERovej RZE ale tá mi pri príkaze píše unknown command.. Tak teda skúsim tú pluginovú verziu. Ale dík za pomoc Link to comment Share on other sites More sharing options...
Guyy 14 Odesláno: 16. Červenec, 2018 Author Share Odesláno: 16. Červenec, 2018 Tak s tou pluginovou verziou je to že prvý krát po zadaní všetkých parametrov dá "Unknown command" a druhý krát ak zadám presne to isté tak už spraví čo má.. Link to comment Share on other sites More sharing options...
Guyy 14 Odesláno: 17. Červenec, 2018 Author Share Odesláno: 17. Červenec, 2018 (upraveno) >> KLIK << Include: #include <a_samp> #include <sscanf2> #include <sampp> #include <i-zcmd> #include <YSI_Coding\y_va> Príkaz: CMD:test(playerid, params[]) { new num; if(sscanf(params, "i", num)) return SendClientMessage(playerid, -1, "{FF0000}[ ! ] {FFFFFF}Test: /test [num]"); va_SendClientMessage(playerid, -1, "{FF0000}[ ! ] {FFFFFF}Num bolo nastavené."); return 1; } crashdetect: [debug] Run time error 6: "Invalid instruction" [debug] Unknown opcode 0x208 at address 0x0001073C [debug] AMX backtrace: [debug] #0 0001073c in ?? (0, -1, 31064) from gamemode.amx [debug] #1 00010928 in public cmd_test (0, 31988) from gamemode.amx [debug] #2 native CallLocalFunction () from samp-server.exe [debug] #3 00005ae4 in public OnPlayerCommandText (0, 31956) from gamemode.amx server.cfg echo Executing Server Config... lanmode 0 rcon_password rcon maxplayers 50 port 7777 hostname SA-MP 0.3 Server gamemode0 gamemode filterscripts plugins crashdetect sampp_server sscanf nativechecker announce 0 chatlogging 0 weburl www.sa-mp.com onfoot_rate 40 incar_rate 40 weapon_rate 40 stream_distance 300.0 stream_rate 1000 maxnpc 0 logtimeformat [%H:%M:%S] language English Edited 17. Červenec, 2018 by Guyy crashdetect Link to comment Share on other sites More sharing options...
Tanga 131 Odesláno: 17. Červenec, 2018 Share Odesláno: 17. Červenec, 2018 Pekný help thread. Čitateľný, zrozumiteľný, so všetkým čo treba. Nemôže byť chybné va_SendClientMessage? Odhadujem z videa a crashdetectu čo si priložil. Skús tam dať obyčajné SCM. Link to comment Share on other sites More sharing options...
Guyy 14 Odesláno: 17. Červenec, 2018 Author Share Odesláno: 17. Červenec, 2018 (upraveno) No, je to tým va_SendClientMessage.. Dík.. Idem skúsiť vymeniť YSI za najnovšie a skúsiť so aj s va_... EDIT:// Ja som mal chybné y_va Dík za pomoc.. Edited 17. Červenec, 2018 by Guyy Link to comment Share on other sites More sharing options...
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