pawn Код:
#include <a_samp>
#include <dini>
#include <dudb>
#include <colors>
#include <cents>
#pragma unused ret_memcpy
#define SERVER_USER_FILE "Info/Players/%s.ini"
#define Help_Dialog (63910)
enum pInfo
{
pSkin,
pDollars,
pCents,
pLevel,
pPos_x,
pPos_y,
pPos_z,
pFacing_Angle,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
main()
{
print("\n----------------------------------");
print(" RPG SERVER");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("PRG 0.01");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registered", "Write Your Pass Below And Get Registered", "Register", "Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registered", "Write Your Pass Below And Login Onto Server", "Login", "Leave");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new Float:Facing_Angle;
new name[MAX_PLAYER_NAME], file[256];
new Float:POS_X, Float:POS_Y, Float:POS_Z;
GetPlayerPos(playerid,POS_X,POS_Y,POS_Z);
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin]);
dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
dini_IntSet(file, "Dollars", GetPlayerMoney(playerid));
dini_IntSet(file, "Cents", GetPlayerCents(playerid));
//dini_IntSet(file, "Pos_x", POS_X);
//dini_IntSet(file, "Pos_y", POS_Y);
//dini_IntSet(file, "Pos_z", POS_Z);
dini_IntSet(file, "Facing Ange", GetPlayerFacingAngle(playerid, Facing_Angle));
}
if(IsPlayerNPC(playerid)) return 1;
gPlayerLogged[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/help", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, Help_Dialog, 0, "Help:", "", "close", "");
return 1;
}
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
return 1;
}
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid,100);
return 1;
}
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid,0);
return 1;
}
if (strcmp("/money", cmdtext, true, 10) == 0)
{
GivePlayerMoney(playerid,250,4);
return 1;
}
return 0;
}
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 name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registered", "Write Your Pass Below And Get Registered", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
dini_IntSet(file, "Dollars",PlayerInfo[playerid][pDollars] = 0);
dini_IntSet(file, "Cents",PlayerInfo[playerid][pCents] = 0);
dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
dini_IntSet(file, "pPos_x",PlayerInfo[playerid][pPos_x] = 0);
dini_IntSet(file, "pPos_y",PlayerInfo[playerid][pPos_y] = 0);
dini_IntSet(file, "pPos_z",PlayerInfo[playerid][pPos_z] = 0);
dini_IntSet(file, "Facing Ange",PlayerInfo[playerid][pFacing_Angle] = 0);
GivePlayerMoney(playerid,100);
gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registered", "Write Your Pass Below And Login Onto Server", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_RED, "[SYSTEM MESSAGE]: Wrong Password Entered.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registered", "Write Your Pass Below And Login Onto Server", "Login", "Leave");
}
else
{
gPlayerLogged[playerid] = 1;
SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
GivePlayerMoney(playerid, dini_Int(file, "Dollars"),dini_Int(file, "Cents"));
SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
//SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
SpawnPlayer(playerid);
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}