4en3rgY Romania
Vizite - Vizite server 2z8bv910
Welcome To 4EN3RGY Romania
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!

4en3rgY Romania


Nu sunteti conectat. Conectați-vă sau înregistrați-vă

Vizite server

Vezi subiectul anterior Vezi subiectul urmator In jos  Mesaj [Pagina 1 din 1]

1Vizite - Vizite server Empty Vizite server Joi 07 Apr 2011, 23:56

Viorel

ViorelFondator

Descriere: Din momentul in care ati pus acest plugin pe server la fiecare conectare de jucator va creste un numar, numarul de vizitatori sa zicem.

Descarcare: AMXX

[sursa=SURSA / SMA]
Cod:
#include <amxmodx>
#include <nvault>

#pragma semicolon 1

new g_vault;
new vizite;

enum Color {
   NORMAL = 1, // clients scr_concolor cvar color
   GREEN, // Green Color
   TEAM_COLOR, // Red, grey, blue
   GREY, // grey
   RED, // Red
   BLUE, // Blue
};

new TeamName[][] = {
   "",
   "TERRORIST",
   "CT",
   "SPECTATOR"
};

public plugin_init() {
   register_plugin( "Vizite" , "0.2" , "Ex3cuTioN" );
   register_clcmd("say /vizite","vizitecmd");
      
   g_vault = nvault_open("vizite_server");
}

public plugin_cfg() {
   g_vault = nvault_open("vizite_server");
}

public plugin_end() {
   Save();
   nvault_close(g_vault);
}

public client_putinserver() {
   vizite +=1;
}

public Load() {
   new vaultkey[64],vaultdata[256];
   
   formatex(vaultkey,63,"VIZITE");
   formatex(vaultdata,255,"%i",vizite);
   
   nvault_get(g_vault,vaultkey,vaultdata,255);

   new showvizite[32];
   
   parse(vaultdata, showvizite, 31);
   
   vizite = str_to_num(showvizite);
   
   return PLUGIN_CONTINUE;
}

public Save() {
   new vaultkey[64],vaultdata[256];
   
   formatex(vaultkey,63,"VIZITE");
   formatex(vaultdata,255,"%i",vizite);
   
   nvault_set(g_vault,vaultkey,vaultdata);
   
   return PLUGIN_CONTINUE;
}


public vizitecmd() {
   Save();
   Load();
   new server[64];
   get_cvar_string("hostname",server,63);
   
   ColorChat(0,GREEN,"[Vizite]^x01 %s a acumulat %i vizite",server,vizite);
   
   return PLUGIN_CONTINUE;
}

ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...) {
   if( !get_playersnum() ) return;
   
   new message[256];

   switch(type)
   {
      case NORMAL: // clients scr_concolor cvar color
      {
         message[0] = 0x01;
      }
      case GREEN: // Green
      {
         message[0] = 0x04;
      }
      default: // White, Red, Blue
      {
         message[0] = 0x03;
      }
   }

   vformat(message[1], 251, msg, 4);

   // Make sure message is not longer than 192 character. Will crash the server.
   message[192] = '^0';

   new team, ColorChange, index, MSG_Type;
   
   if(id)
   {
      MSG_Type = MSG_ONE;
      index = id;
   } else {
      index = FindPlayer();
      MSG_Type = MSG_ALL;
   }
   
   team = get_user_team(index);
   ColorChange = ColorSelection(index, MSG_Type, type);

   ShowColorMessage(index, MSG_Type, message);
      
   if(ColorChange)
   {
      Team_Info(index, MSG_Type, TeamName[team]);
   }
}

ShowColorMessage(id, type, message[]) {
   static bool:saytext_used;
   static get_user_msgid_saytext;
   if(!saytext_used)
   {
      get_user_msgid_saytext = get_user_msgid("SayText");
      saytext_used = true;
   }
   message_begin(type, get_user_msgid_saytext, _, id);
   write_byte(id);
   write_string(message);
   message_end();   
}

Team_Info(id, type, team[])
{
   static bool:teaminfo_used;
   static get_user_msgid_teaminfo;
   if(!teaminfo_used)
   {
      get_user_msgid_teaminfo = get_user_msgid("TeamInfo");
      teaminfo_used = true;
   }
   message_begin(type, get_user_msgid_teaminfo, _, id);
   write_byte(id);
   write_string(team);
   message_end();

   return 1;
}

ColorSelection(index, type, Color:Type)
{
   switch(Type)
   {
      case RED:
      {
         return Team_Info(index, type, TeamName[1]);
      }
      case BLUE:
      {
         return Team_Info(index, type, TeamName[2]);
      }
      case GREY:
      {
         return Team_Info(index, type, TeamName[0]);
      }
   }

   return 0;
}

FindPlayer()
{
   new i = -1;

   while(i <= get_maxplayers())
   {
      if(is_user_connected(++i))
         return i;
   }

   return -1;
}
[/sursa]

Nume: Vizite
Versiune:
    0.1 - prima publicare
    0.2
      - optimizare cod
      - format -> formatex


Instalare:
1. Fisierul vizite2.sma il puneti in addons/amxmodx/scripting
2. Fisierul vizite2.amxx il puneti in addons/amxmodx/plugins
3. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:
Cod:
vizite2.amxx

Comenzi publice (se tasteaza in joc prin apasarea tastei Y):
    /vizite - afiseaza numarul de vizite acumulate


Module necesare (se sterge ; din fata modulului de mai jos; acestea le gasiti in fisierul amxmodx\configs\modules.ini):
- nVault

Vezi subiectul anterior Vezi subiectul urmator Sus  Mesaj [Pagina 1 din 1]

Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum

 

Copyright @ 2010-2024 by 4en3rgY ~> All rights reserved.