03.08.2013, 15:56
Hello, i got a problem with my GM. I can use commands while i'm not logged in. Can someone help me ?. I tried somethin with mutting when player connects but it don't work.
PS: It can be only done if i press F6. (because T doesn't work)
Thank You
PS: It can be only done if i press F6. (because T doesn't work)
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <sscanf2>
#include "../include/gl_common.inc"
#include <YSI\y_master>
#define TEAM_POLITIE 1
#define TEAM_TRIAD 2
#define TEAM_MUNCITOR 3
#define TEAM_HITMAN 4
#define COLOR_ROSU 0xFF0000FF
#define COLOR_ALBASTRU 0x0000FFFF
#define COLOR_GRI 0x808080FF
#define COLOR_GALBEN 0xFFFF00FF
#define COLOR_ALB 0xFFFFFFFF
#define COLOR_PORTOCALIU 0xFF8000FF
#define COLOR_ALB_EMBED "{FFFFFF}"
#define COLOR_ROSU_EMBED "{F81414}"
#define COLOR_VERDE_EMBED "{00FF22}"
#define COLOR_GALBEN_EMBED "{00CED1}"
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/tdmd/users/%s.ini"
enum pInfo
{
pPassword,
pCash,
pAdmin,
pKills,
pDeaths,
pLevel,
pCasa,
pBanca
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new total_vehicles_from_files=0;
new gTeam[MAX_PLAYERS];
new pMutedSpawn[MAX_PLAYERS] = 0;
main()
{
print("TDM D v1.0 Loaded - Succes");
}
public OnGameModeInit()
{
SetGameModeText("TDM D v1.0");
//Classid 0,1 - POLITIE
AddPlayerClass(286,-1590.1783,716.3723,-5.2422,271.5280,WEAPON_KNIFE,1,WEAPON_COLT45,0x7FFFFFFF,WEAPON_TEC9,0x7FFFFFFF);
AddPlayerClass(281,-1606.2870,676.0802,-5.2422,359.2622,WEAPON_KNIFE,1,WEAPON_COLT45,0x7FFFFFFF,WEAPON_TEC9,0x7FFFFFFF);
//Classid 2,3 - TRIAD
AddPlayerClass(117,-2190.3599,641.3010,49.4375,88.5436,WEAPON_BAT,1,WEAPON_COLT45,0x7FFFFFFF,WEAPON_UZI,0x7FFFFFFF);
AddPlayerClass(120,-2189.8606,608.9390,35.1641,86.6636,WEAPON_BAT,1,WEAPON_COLT45,0x7FFFFFFF,WEAPON_UZI,0x7FFFFFFF);
//Classid 4,5 - MUNCITOR
AddPlayerClass(27,-2084.1450,229.6412,35.6909,268.0180,WEAPON_KNIFE,1, WEAPON_COLT45,0x7FFFFFFF,WEAPON_TEC9, 0x7FFFFFFF);
AddPlayerClass(260,-2026.6230,179.5202,28.8359,278.3814,WEAPON_KNIFE,1, WEAPON_COLT45,0x7FFFFFFF,WEAPON_TEC9, 0x7FFFFFFF);
//Classid 6,7 - HITMAN
AddPlayerClass(185,-1660.3741,1384.4176,9.8047,134.6696,WEAPON_BAT, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_UZI, 0x7FFFFFFF);
AddPlayerClass(186,-1678.8684,1355.5388,7.1722,52.5988,WEAPON_BAT, 1, WEAPON_COLT45, 0x7FFFFFFF, WEAPON_UZI, 0x7FFFFFFF);
total_vehicles_from_files += LoadStaticVehiclesFromFile("tdmd/masini.txt");
return 1;
}
public OnGameModeExit()
{
return 1;
}
//Setare Pozitie Alegere Echipe + Setari Echipa
public OnPlayerRequestClass(playerid,classid)
{
SetPlayerInterior(playerid, 3);
SetPlayerPos(playerid,-2651.0171,1410.2346,906.2734);
SetPlayerFacingAngle(playerid,90.3552);
SetPlayerCameraPos(playerid,-2646.0171,1410.2346,906.2734);
SetPlayerCameraLookAt(playerid,-2651.0171,1410.2346,906.2734);
SetPlayerFacingAngle (playerid,270.3552);
switch(classid)
{
case 0,1:
{
GameTextForPlayer(playerid,"~b~politie",3000,6);
SetPlayerTeam(playerid,TEAM_POLITIE);
gTeam[playerid] = TEAM_POLITIE;
SetPlayerColor(playerid,COLOR_ALBASTRU);
}
case 2,3:
{
GameTextForPlayer(playerid,"~r~triad",3000,6);
SetPlayerTeam(playerid, TEAM_TRIAD);
gTeam[playerid] = TEAM_TRIAD;
SetPlayerColor(playerid, COLOR_ROSU);
}
case 4,5:
{
GameTextForPlayer(playerid,"~y~muncitor",3000,6);
SetPlayerTeam(playerid,TEAM_MUNCITOR);
gTeam[playerid] = TEAM_MUNCITOR;
SetPlayerColor(playerid,COLOR_GALBEN);
}
case 6,7:
{
GameTextForPlayer(playerid, "~w~hitman",3000,6);
SetPlayerTeam(playerid,TEAM_HITMAN);
gTeam[playerid] = TEAM_HITMAN;
SetPlayerColor(playerid,COLOR_GRI);
}
}
return 1;
}
//Setare Culoare Echipa
SetPlayerToTeamColor(playerid)
{
if (gTeam[playerid] == TEAM_POLITIE)
{
SetPlayerColor(playerid,COLOR_ALBASTRU);
}
else if (gTeam[playerid] == TEAM_TRIAD)
{
SetPlayerColor(playerid,COLOR_ROSU);
}
else if (gTeam[playerid] == TEAM_MUNCITOR)
{
SetPlayerColor(playerid,COLOR_GALBEN);
}
else if (gTeam[playerid] == TEAM_HITMAN)
{
SetPlayerColor(playerid,COLOR_GRI);
}
}
public OnPlayerConnect(playerid)
{
pMutedSpawn[playerid] = 1;
SendClientMessage(playerid, COLOR_PORTOCALIU, "Bine ai venit pe {FFFFFF}Dedicatii.Eu TDM v1.0");
SendClientMessage(playerid, COLOR_PORTOCALIU, "Acest server foloseste un gamemode de tip {FFFFFF}TEAM DEATHMATCH");
SendClientMessage(playerid, COLOR_PORTOCALIU, "Pentru ajutor foloseste {FFFFFF}/help {FF8000},iar pentru comenzi {FFFFFF}/cmd");
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_ALB_EMBED"Login",""COLOR_ALB_EMBED"Introdu parola ta mai jos","Login","Iesi");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COLOR_ALB_EMBED"Register...",""COLOR_ALB_EMBED"Introdu parola ta mai jos pentru a te inregistra","Register","Iesi");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Casa",PlayerInfo[playerid][pCasa]);
INI_WriteInt(File,"Banca",PlayerInfo[playerid][pBanca]);
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
SetPlayerInterior(playerid, 0);
pMutedSpawn[playerid] = 0;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
GivePlayerMoney(killerid, 250);
SendClientMessage(playerid, COLOR_PORTOCALIU, "Ai murit si ai pierdut $100");
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof(string),"L-ai omorat pe {FFFFFF}%s{FF8000} si ai primit $250.",pName);
SendClientMessage(killerid, COLOR_PORTOCALIU, string);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COLOR_ALB_EMBED"Register...",""COLOR_ROSU_EMBED"Parola Invalida.\n"COLOR_ALB_EMBED"Introdu parola ta mai jos pentru a inregistra un account nou.","Register","Iesi");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Level",0);
INI_WriteInt(File,"Casa",0);
INI_WriteInt(File,"Banca",0);
INI_Close(File);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COLOR_ALB_EMBED"Success!",""COLOR_ALB_EMBED"Inregistrare Completa! Reconecteaza-te pentru a salva stats-urile.","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COLOR_ALB_EMBED"Success!",""COLOR_VERDE_EMBED"Te-ai logat cu succes!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_ALB_EMBED"Login",""COLOR_ROSU_EMBED"Ai introdus o parola gresita.\n"COLOR_ALB_EMBED"Introdu parola ta mai jos pentru a te loga","Login","Iesi");
}
return 1;
}
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
if(IsPlayerConnected(playerid))
{
new statstring[128];
format(statstring, sizeof(statstring), "| Stats-urile Tale : | Kills: %d | Deaths: %d | Cash: $%d | Banca: $%d | Casa: %d | Admin: %d |",PlayerInfo[playerid][pKills],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pBanca],PlayerInfo[playerid][pCasa],PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid,-1, statstring);
}
return 1;
}
return 0;
}
public OnPlayerText(playerid,text[])
{
if(pMutedSpawn[playerid] == 1) return 0;
return 0;
}
//Stats pentru Login System
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPassword]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("Casa",PlayerInfo[playerid][pCasa]);
INI_Int("Banca",PlayerInfo[playerid][pBanca]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
//Hasher
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
//Comenzi
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3) {
new PID;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_ALB, "SINTAXA: /kick [playerid] [motiv]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_ALB, "EROARE: Jucatorul nu este conectat");
format(str, sizeof(str), "'%s' a dat kick lui '%s'. Motiv: %s ", Adminname, Playername, reason);
SendClientMessageToAll(COLOR_PORTOCALIU, str);
Kick(PID);
}
else
{
SendClientMessage(playerid, COLOR_ALB, "EROARE: Nu ai permisiunea sa folosesti aceasta comanda");
}
return 1;
}