Ale chcialem nowy rozpoczac poniewaz na tamtych nic nie bylo
Moje pytanie brzmi czy da sie dodac do cod stary magazyn na perki?
Jak by mi ktos opisal ...
Spoiler
public Magazyn(id) { if(!is_user_alive(id)) return 0; #if defined ZAPISUJ Wczytaj(id); #endif new menu = menu_create("\yMagazyn na perki \dby \rGoliath", "Magazyn_Handler"); new text[33], perk; for(new i=1; i<=ILOSC_SLOTOW; i++) { perk = ArrayGetCell(aPerki, id*ILOSC_SLOTOW+i) if(!perk) formatex(text, 32, "Pusty slot"); else { #if defined WYTRZYMALOSC cod_get_perk_name(perk, text, 32); format(text, 32, "%s %i/%i", text, ArrayGetCell(aWytrzymalosc, id*ILOSC_SLOTOW+i), max_wytrzymalosc); #else cod_get_perk_name(perk, text, 32); #endif } menu_additem(menu, text); } menu_setprop(menu, MPROP_NEXTNAME, "Dalej"); menu_setprop(menu, MPROP_EXITNAME, "Wyjdz"); menu_setprop(menu, MPROP_BACKNAME, "Wstecz"); menu_display(id, menu); return 1; } public Magazyn_Handler(id, menu, item) { if(item++ == MENU_EXIT) return 0; new perk = ArrayGetCell(aPerki, id*ILOSC_SLOTOW+item), wartosc = ArrayGetCell(aWartosc, id*ILOSC_SLOTOW+item); new wartosc_gracza, perk_gracza = cod_get_user_perk(id, wartosc_gracza); #if defined WYTRZYMALOSC new wytrzymalosc = ArrayGetCell(aWytrzymalosc, id*ILOSC_SLOTOW+item); new wytrzymalosc_gracza = cod_get_perk_durability(id); #endif if(perk) { if(Uzyto[id] & (1<<item)) { client_print(id, print_center, "Nie mozesz wyjac perku, ktory dopiero wlozyles!"); Magazyn(id); return 0; } #if defined WYTRZYMALOSC if(perk_gracza) { ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, perk_gracza); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, wartosc_gracza); ArraySetCell(aWytrzymalosc, id*ILOSC_SLOTOW+item, wytrzymalosc_gracza); cod_set_user_perk(id, perk, wartosc, 0); cod_set_perk_durability(id, wytrzymalosc); Uzyto[id] |= (1<<item); } else { cod_set_user_perk(id, perk, wartosc, 0); cod_set_perk_durability(id, wytrzymalosc); ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, 0); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, 0); ArraySetCell(aWytrzymalosc, id*ILOSC_SLOTOW+item, 0); } #else if(perk_gracza) { ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, perk_gracza); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, wartosc_gracza); cod_set_user_perk(id, perk, wartosc, 0); Uzyto[id] |= (1<<item); } else { cod_set_user_perk(id, perk, wartosc, 0); ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, 0); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, 0); } #endif } else { #if defined WYTRZYMALOSC if(!perk_gracza) { client_print(id, print_center, "Nie masz zadnego perku!"); Magazyn(id); return 0; } else { ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, perk_gracza); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, wartosc_gracza); ArraySetCell(aWytrzymalosc, id*ILOSC_SLOTOW+item, wytrzymalosc_gracza); cod_set_user_perk(id, 0, 0, 0); cod_set_perk_durability(id, 0); Uzyto[id] |= (1<<item); } #else if(!perk_gracza) { client_print(id, print_center, "Nie masz zadnego perku!"); Magazyn(id); return 0; } else { ArraySetCell(aPerki, id*ILOSC_SLOTOW+item, perk_gracza); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+item, wartosc_gracza); cod_set_user_perk(id, 0, 0, 0); Uzyto[id] |= (1<<item); } #endif } #if defined ZAPISUJ Zapisz(id); #endif Magazyn(id); return 0; } #if defined ZAPISUJ && !defined WYTRZYMALOSC public Zapisz(id) { if(!is_user_connected(id)) return 0; new key[40], value[513], identyfikator[33], val_len = 0; switch(typ_zapisu) { case 1: get_user_name(id, identyfikator, charsmax(identyfikator)); case 2: get_user_authid(id, identyfikator, charsmax(identyfikator)); case 3: get_user_ip(id, identyfikator, charsmax(identyfikator)); } formatex(key, charsmax(key), "%s-%i", identyfikator, typ_zapisu); new text[33], perk, wartosc; for(new i=1; i<=ILOSC_SLOTOW; i++) { perk = ArrayGetCell(aPerki, id*ILOSC_SLOTOW+i); wartosc = ArrayGetCell(aWartosc, id*ILOSC_SLOTOW+i); if(perk) { cod_get_perk_name(perk, text, charsmax(text)); replace_all(text, charsmax(text), " ", "_"); val_len += formatex(value[val_len], charsmax(value)-val_len, "%s#%i#", text, wartosc); } else val_len += formatex(value[val_len], charsmax(value)-val_len, "Brak#-1#"); } nvault_set(vault, key, value); return 0; } public Wczytaj(id) { if(!is_user_connected(id)) return 0; new key[40], identyfikator[33]; switch(typ_zapisu) { case 1: get_user_name(id, identyfikator, charsmax(identyfikator)); case 2: get_user_authid(id, identyfikator, charsmax(identyfikator)); case 3: get_user_ip(id, identyfikator, charsmax(identyfikator)); } formatex(key, charsmax(key), "%s-%i", identyfikator, typ_zapisu); new text[2*ILOSC_SLOTOW+2][33], value[513]; nvault_get(vault, key, value, 512); explode(value, '#', text, 2*ILOSC_SLOTOW+1, 32); for(new i=0; i<ILOSC_SLOTOW; i++) { new perk, wartosc; replace_all(text[2*i], 32, "_", " "); perk = cod_get_perkid(text[2*i]); wartosc = str_to_num(text[2*i+1]); if(perk) { ArraySetCell(aPerki, id*ILOSC_SLOTOW+i+1, perk); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+i+1, wartosc); } else { ArraySetCell(aPerki, id*ILOSC_SLOTOW+i+1, 0); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+i+1, -1); } } return 0; } #endif #if defined ZAPISUJ && defined WYTRZYMALOSC public Zapisz(id) { if(!is_user_connected(id)) return 0; new key[40], value[513], identyfikator[33], val_len = 0; switch(typ_zapisu) { case 1: get_user_name(id, identyfikator, charsmax(identyfikator)); case 2: get_user_authid(id, identyfikator, charsmax(identyfikator)); case 3: get_user_ip(id, identyfikator, charsmax(identyfikator)); } formatex(key, charsmax(key), "%s-%i", identyfikator, typ_zapisu); new text[33], perk, wartosc, wytrzymalosc; for(new i=1; i<=ILOSC_SLOTOW; i++) { perk = ArrayGetCell(aPerki, id*ILOSC_SLOTOW+i); wartosc = ArrayGetCell(aWartosc, id*ILOSC_SLOTOW+i); wytrzymalosc = ArrayGetCell(aWytrzymalosc, id*ILOSC_SLOTOW+i); if(perk) { cod_get_perk_name(perk, text, charsmax(text)); replace_all(text, charsmax(text), " ", "_"); val_len += formatex(value[val_len], charsmax(value)-val_len, "%s#%i#%i#", text, wartosc, wytrzymalosc); } else val_len += formatex(value[val_len], charsmax(value)-val_len, "Brak#-1#0#"); } nvault_set(vault, key, value); return 0; } public Wczytaj(id) { if(!is_user_connected(id)) return 0; new key[40], identyfikator[33]; switch(typ_zapisu) { case 1: get_user_name(id, identyfikator, charsmax(identyfikator)); case 2: get_user_authid(id, identyfikator, charsmax(identyfikator)); case 3: get_user_ip(id, identyfikator, charsmax(identyfikator)); } formatex(key, charsmax(key), "%s-%i", identyfikator, typ_zapisu); new text[3*ILOSC_SLOTOW+2][33], value[513]; nvault_get(vault, key, value, 512); explode(value, '#', text, 3*ILOSC_SLOTOW+1, 32); new perk, wartosc, wytrzymalosc; for(new i=0; i<ILOSC_SLOTOW; i++) { replace_all(text[3*i], 32, "_", " "); perk = cod_get_perkid(text[3*i]); wartosc = str_to_num(text[3*i+1]); wytrzymalosc = str_to_num(text[3*i+2]); if(perk) { ArraySetCell(aPerki, id*ILOSC_SLOTOW+i+1, perk); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+i+1, wartosc); ArraySetCell(aWytrzymalosc, id*ILOSC_SLOTOW+i+1, wytrzymalosc); } else { ArraySetCell(aPerki, id*ILOSC_SLOTOW+i+1, 0); ArraySetCell(aWartosc, id*ILOSC_SLOTOW+i+1, -1); ArraySetCell(aWytrzymalosc, id*ILOSC_SLOTOW+i+1, 0); } } return 0; }
Nie wiem czy dobre to jest na cod stary a jak nie to prosilbym o poprawienie pod stary cod
Za POMOC +
Użytkownik Jotpe edytował ten post 23.12.2012 11:52