Jump to content
  • 0

pomoc Help s ukladáním


Pingvin

Dotaz

Ahoj pomohl by mi nebo ukazal by mi někdo jak udelat ukladani obcanky.
Mam tam už udělaní ale když vždy resetnu server tak se obcanka smaze a musim si jí znova koupit.
proto prosím kdo by mi ukázal jak udělat ukládání když si jí hráč koupí aby jí měl na furt  :d
 
Tady je kod: (vím že sem nemám ávat dlouhé kody ale nevím jak to udělat do nákého formátu proto se předem omlouvám !)

 

 

 

#include <a_samp>
#include <dof2>
#include <dudb>
#include <izcmd>
 
#define Hesla "/Lukas/%s.txt"
 
#define MAX_PLAYERS_EX 100
 
#pragma unused ret_memcpy
 
new NahranyCas[MAX_PLAYERS];
new Sekundy[MAX_PLAYERS_EX];
new Minuty[MAX_PLAYERS_EX];
new Hodiny[MAX_PLAYERS_EX];
 
new IP[16];
 
new Float:poziceX;
new Float:poziceY;
new Float:poziceZ;
 
new zabiti[MAX_PLAYERS];
new umrti[MAX_PLAYERS];
 
new Obcanka[MAX_PLAYERS];
 
 
forward Cas();
 
public OnGameModeInit()
{
 
SetGameModeText("Blank Script");
 
return 1;
}
 
public OnGameModeExit()
{
DOF2_Exit();
return 1;
}
 
public OnPlayerRequestClass(playerid, classid)
{
 
return 1;
}
 
public OnPlayerConnect(playerid)
{
 
    GetPlayerIp(playerid, IP, sizeof(IP));
 
    NahranyCas[playerid] = SetTimer("Cas",1000,1);
 
new nick[MAX_PLAYER_NAME],  soubor[64], string[128];
GetPlayerName(playerid, nick, sizeof(nick));
format(soubor, sizeof(soubor), Hesla, nick);
if (DOF2_FileExists(soubor))
{
format(string,sizeof(string),"{00B6FF}Vítej zpátky na serveru, {016BC3}%s!\n{FFFFFF}Zadej svoje heslo:",nick);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD,"Přihlašování...",string, "HOTOVO","ODEJIT");
}
else
{
format(string,sizeof(string),"{00B6FF}Vítej na serveru, {016BC3}%s!\n{FFFFFF}Zadej svoje nové heslo:",nick);
  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD,"Registrace...",string, "HOTOVO","ODEJIT");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(NahranyCas[playerid]);
 
    new Float:x;
new Float:y;
new Float:z;
 
GetPlayerPos(playerid,x,y,z);
poziceX = x;
poziceY = y;
poziceZ = z;
 
    new nick[MAX_PLAYER_NAME], soubor[64];
    GetPlayerName(playerid, nick, sizeof(nick));
  format(soubor, sizeof(soubor), Hesla, nick);
    DOF2_SetInt(soubor, "hodiny", Hodiny[playerid]);
  DOF2_SetInt(soubor, "minuty", Minuty[playerid]);
    DOF2_SetInt(soubor, "sekundy", Sekundy[playerid]);
    DOF2_SetInt(soubor, "Obcanka" ,Obcanka[playerid]);
    DOF2_SetInt(soubor, "penize", GetPlayerMoney(playerid));
    DOF2_SetInt(soubor, "poziceX", floatround(poziceX));
DOF2_SetInt(soubor, "poziceY", floatround(poziceY));
  DOF2_SetInt(soubor, "poziceZ", floatround(poziceZ));
  DOF2_SetInt(soubor, "zabil", zabiti[playerid]);
  DOF2_SetInt(soubor, "umrel", umrti[playerid]);
    DOF2_SaveFile();
return 1;
}
 
public OnPlayerSpawn(playerid)
{
new nick[MAX_PLAYER_NAME], soubor[64];
GetPlayerName(playerid, nick, sizeof(nick));
format(soubor, sizeof(soubor), Hesla, nick);
if( DOF2_GetFloat( soubor , "poziceX" ) == 0.0 )
{
SetPlayerSkin(playerid, 45);
    SetPlayerMoney(playerid,10000);
SetPlayerPos(playerid, 1088.0276,1073.7034,10.8382); //NASTAVENÍ POZICE NA KTERÉ SE SPAWNE NOVÝ HRÁČ
}else{
SetPlayerPos(playerid, DOF2_GetFloat(soubor, "poziceX"), DOF2_GetFloat(soubor, "poziceY"), DOF2_GetFloat(soubor,"poziceZ"));
}
return 1;
}
 
public OnPlayerDeath(playerid, killerid, reason)
{
zabiti[killerid] ++;
umrti[playerid] ++;
return 1;
}
 
public OnVehicleSpawn(vehicleid)
{
return 1;
}
 
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
 
public OnPlayerText(playerid, text[])
{
return 1;
}
 
public OnPlayerCommandText(playerid, cmdtext[])
{
new wstring[128];
format(wstring,128, "{FF0000}[ Server ]{00FF00} Příkaz {FF0000}%s {00FF00}neexistuje", cmdtext);
return SendClientMessage(playerid,-1, wstring);
}
 
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
 
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
 
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
 
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
 
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
 
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
 
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
 
public OnRconCommand(cmd[])
{
return 1;
}
 
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
 
public OnObjectMoved(objectid)
{
return 1;
}
 
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
 
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
 
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
 
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
 
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
 
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
 
public OnPlayerExitedMenu(playerid)
{
return 1;
}
 
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
 
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
 
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
 
public OnPlayerUpdate(playerid)
{
return 1;
}
 
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
 
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
 
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
 
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
 
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
    {
        new nick[MAX_PLAYER_NAME], soubor[64], string[128];
        GetPlayerName(playerid, nick, sizeof(nick));
        format(soubor, sizeof(soubor), Hesla, nick);
          if(!response)
return Kick(playerid);
if (!strlen(inputtext)) return
 
format(string,sizeof(string),"{00B6FF}Vítej na serveru, {016BC3}%s!\n{FFFFFF}Zadej svoje nové heslo:",nick);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD,"Registrace...",string, "HOTOVO","ODEJIT");
 
DOF2_CreateFile(soubor);
       DOF2_SetInt(soubor, "Heslo", udb_hash(inputtext));
       DOF2_SetInt(soubor, "hodiny", Hodiny[playerid]);
DOF2_SetInt(soubor, "minuty", Minuty[playerid]);
  DOF2_SetInt(soubor, "sekundy", Sekundy[playerid]);
  DOF2_SetInt(soubor, "Obcanka", Obcanka[playerid]);
  DOF2_SetInt(soubor, "penize", GetPlayerMoney(playerid));
  DOF2_SetString(soubor, "IP adresa", IP);
  DOF2_SetInt(soubor, "zabil", 0);
  DOF2_SetInt(soubor, "umrel", 0);
       DOF2_SaveFile();
 
       format(string, 128, "Byl jsi úspěšně zaregistrovaný na jméno %s. Tvoje heslo je: {FF0000}%s.", nick, inputtext);
       SendClientMessage(playerid, 0x66F2BEFF, string);
 
    StopAudioStreamForPlayer(playerid);
}
 
    if (dialogid == 2)
    {
        new nick[MAX_PLAYER_NAME], soubor[64], string[128];
        GetPlayerName(playerid, nick, sizeof(nick));
        format(soubor, sizeof(soubor), Hesla, nick);
        if(!response)
return Kick(playerid);
  new tmp;
tmp = DOF2_GetInt(soubor, "Heslo");
        if(udb_hash(inputtext) != tmp)
{
  format(string,sizeof(string),"{00B6FF}Vítej zpátky na serveru, {016BC3}%s!\n{FF4848}Zadal jsi špatné heslo!",nick);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD,"Přihlašování...",string, "HOTOVO","ODEJIT");
 
}
        else
        {
            SendClientMessage(playerid,0x66F2BEFF, "Byl jsi {FF0000}úspěšně přihlášený!!");
DOF2_SetInt(soubor, "hodiny", Hodiny[playerid]);
            DOF2_SetInt(soubor, "minuty", Minuty[playerid]);
   DOF2_SetInt(soubor, "sekundy", Sekundy[playerid]);
   DOF2_SetString(soubor, "IP adresa", IP);
   GivePlayerMoney(playerid, DOF2_GetInt(soubor, "penize"));
            DOF2_GetInt(soubor, "zabil");
            DOF2_GetInt(soubor, "umrel");
            DOF2_GetInt(soubor, "Obcanka",Obcanka[playerid]);
 
 
    StopAudioStreamForPlayer(playerid);
        }
}
  if(dialogid == 3)
  {
  new nick[MAX_PLAYER_NAME], slozka[64];
    GetPlayerName(playerid, nick, sizeof(nick));
  format(slozka, sizeof(slozka), Hesla, nick);
  if(response)
  {
  if(udb_hash(inputtext) != DOF2_GetInt(slozka, "Heslo"))
  {
  ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"Změna hesla","{00B6FF}Zadej prosím svoje staré heslo\n{FF4848}Zadal jsi špatné heslo!","Další","Zavřít");
  }
  else
  {
  ShowPlayerDialog(playerid,4,DIALOG_STYLE_INPUT,"Změna hesla","{00B6FF}Zadej prosím svoje nové heslo","Hotovo","Zavřít");
}
}
}
if(dialogid == 4)
{
  new nick[MAX_PLAYER_NAME], slozka[64];
    GetPlayerName(playerid, nick, sizeof(nick));
  format(slozka, sizeof(slozka), Hesla, nick);
if(response)
{
DOF2_SetInt(slozka, "Heslo", udb_hash(inputtext));
DOF2_SaveFile();
SendClientMessage(playerid,0x66F2BEFF,"Heslo bylo úspěšně změněho! Svoje heslo si zapamatuj pro další přihlášení.");
}
}
return 0;
    }
    
    public Cas()
    {
for(new i;i<MAX_PLAYERS_EX;i++)
{
  Sekundy[i] ++;
  if
  (Sekundy[i] == 60)
{
Minuty[i] ++;
  Sekundy[i] = 0;
}
else if
(Minuty[i] == 60)
{
Hodiny[i] ++;
    Minuty[i] = 0;
    Sekundy[i] = 0;
}
  else if
(Minuty[i] == 60 && Sekundy[i] == 60)
{
Hodiny[i] ++;
Minuty[i] = 0;
Sekundy[i] = 0;
}
}
return true;
}
 
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
//==============================================================================================================================================//
//                                                            [ Příkazy ]                                                                       //
//==============================================================================================================================================//
CMD:obcanka(playerid, params[])
{
if(Obcanka[playerid] == 1) return SendClientMessage(playerid,-1,"{00FF00}Hráč jíž {FF0000}občanku {00FF00}má :D");
Obcanka[playerid] = 1;
 
SendClientMessage(playerid,-1,"Dostal jsi Občanku :D");
return 1;
}
//==============================================================================
CMD:heslo(playerid, params[])
{
ShowPlayerDialog(playerid,3,DIALOG_STYLE_INPUT,"Změna hesla","{00B6FF}Zadej prosím svoje staré heslo","Další","Zavřít");
    return 1;
}
 
CMD:info(playerid, params[])
{
new string[300], nick[MAX_PLAYER_NAME];
GetPlayerName(playerid, nick, sizeof(nick));
    format(string,sizeof(string),"{00B6FF}Herní nick: {FFFFFF}%s\n{00B6FF}IP adresa:{FFFFFF}%s\n{00B6FF}Herní peníze: {FFFFFF}%d\n{00B6FF}Nahraný čas: {FFFFFF}%d:%d\n{00B6FF}Skin: {FFFFFF}%d\n{00B6FF}Zabití: {FFFFFF}%d\n{00B6FF}Umrtí: {FFFFFF}%d\n{00B6FF}Občanka: {FFFFFF}%d",nick, IP, GetPlayerMoney(playerid),Hodiny, Minuty, GetPlayerSkin(playerid), zabiti[playerid], umrti[playerid],Obcanka[playerid]);
ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Informace",string,"OK","");
return 1;
}

 

 

Link to comment
Share on other sites

1 odpověd na tuto otázku

Recommended Posts

  • 0
  • Hlavní moderátor

 

 

Tady je kod: (vím že sem nemám ávat dlouhé kody ale nevím jak to udělat do nákého formátu proto se předem omlouvám !)

Máš to napsáno v pravidlech sekce Pomoc a sám jsem to už jednou říkal.

[spoiler][code]SEM vložíš dlouhý kód[/code][/spoiler]

Spoiler a code

Upraveno, ale příště již za bodované varování.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...