01.05.2011, 20:44
Well, I can't seem to figure out what is wrong - Nothing is loading, and I don't know where it's coming from other than the account system. Since I can't pinpoint it, I figure I could post my whole script on the SA:MP forums and see if anyone can figure it out - Since it's from scratch, it's not very long, so that's why I figured it would be okay to post the whole thing. Well.. Can anyone figure it out?
tl;dr
Account system is bugged to hell.
tl;dr
Account system is bugged to hell.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <djson>
#include <streamer>
#define ORANGE 0xEBA613FF
//SERVER CONFIGURATION
#define cfg_SERVER_NAME "Land o' Casinos Roleplay" //PARAMETERS: SERVER NAME
#define cfg_SERVER_VERSION "LoC v1.0" //PARAMETERS: GAMEMODE TEXT
#define cfg_SERVER_MAXPLAYERS "100" //PARAMETERS: Number value (1-500 as of 0.3c) [For Speed Enhancements]
#define cfg_CJ_RUN "on" //PARAMETERS: ON/OFF
//DYNAMIC CONFIGURATION
#define ICON_FILE_NAME "MapIcons.txt"
#define VEHICLE_FILE_NAME "Vehicles.txt"
#define PICKUP_FILE_NAME "Pickups.txt"
#define LABEL_FILE_NAME "Labels.txt"
#define LOGINDIALOG 0
#define REGISTERDIALOG 1
#define PFiles "Userfiles/%s.json"
enum _PINFO {
Kills,
Deaths,
Authorization,
Cash,
ContractAmount,
VIPLevel,
Faction,
Rank,
Leader
}
new
PVar[MAX_PLAYERS][_PINFO],
global_ConnectedPlayers = 0,
global_ConnectedAdmins = 0,
ServerHasJustBeenRestarted = 0,
OnAdministratorDuty[MAX_PLAYERS] = 0,
PlayerIsLoggedIn[MAX_PLAYERS] = 0;
new aWeaponNames[][32] =
{
{"Unarmed"}, {"BrassKnuckles"}, {"GolfClub"}, {"NightStick"}, {"Knife"}, {"BaseballBat"},
{"Shovel"}, {"PoolCue"}, {"Katana"}, {"Chainsaw"}, {"PurpleDildo"}, {"BigWhiteVibrator"},
{"MedWhiteVibrator"}, {"SmlWhiteVibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"},
{"Molotov"}, {"Empty Slot 1"}, {"Empty Slot 2"}, {"Empty Slot 3"}, {"Colt45"}, {"SDPistol"},
{"DesertEagle"}, {"Shotgun"}, {"SawnoffShotgun"}, {"Spas12"}, {"Mac10"},
{"MP5"}, {"AK47"}, {"M4"}, {"Tec9"}, {"CountryRifle"}, {"Sniper"}, {"RPG"},
{"HeatRPG"}, {"Flamethrower"}, {"Minigun"}, {"Satchel"}, {"Detonator"},
{"SprayCan"}, {"Extinguisher"}, {"Camera"}, {"NVGoggles"}, {"IRGoggles"},
{"Parachute"}, {"Fake Pistol"}
};
forward Float:GetDistanceBetweenPlayers(playerid,targetplayerid);
main()
{
return 1;
}
public OnGameModeInit()
{
new
Pickup,
Vehicles,
Labels,
Icons;
//SERVER SETUP
print("[+] SERVER CONFIGURATION");
print(" ");
SendRconCommand("hostname " cfg_SERVER_NAME);
printf("\t[-] Server Name: %s", cfg_SERVER_NAME);
SetGameModeText(cfg_SERVER_VERSION);
printf("\t[-] Server Version: %s", cfg_SERVER_VERSION);
printf("\t[-] Server Max Players: %d", strval(cfg_SERVER_MAXPLAYERS));
//OTHER STUFF
if(strcmp(cfg_CJ_RUN, "ON", true) == 0) { print("\t[-] CJ Run: [ON]"); UsePlayerPedAnims(); }
else if(strcmp(cfg_CJ_RUN, "OFF", true) == 0) { print("\t[-] CJ Run: [OFF]"); }
else { print("\t[-] CJ Run: (Invalid Option - Reverted to \"OFF\")"); }
Pickup = AddPickupFromFile(PICKUP_FILE_NAME);
printf("\t[-] %i Pickup(s) loaded from \"%s\"", Pickup, PICKUP_FILE_NAME);
Vehicles = AddVehiclesFromFile(VEHICLE_FILE_NAME);
printf("\t[-] %i Vehicle(s) loaded from \"%s\"", Vehicles, VEHICLE_FILE_NAME);
Labels = AddLabelsFromFile(LABEL_FILE_NAME);
printf("\t[-] %i Label(s) loaded from \"%s\"", Labels, LABEL_FILE_NAME);
Icons = AddMapIconFromFile(ICON_FILE_NAME);
printf("\t[-] %i Map Icon(s) loaded from \"%s\"", Icons, ICON_FILE_NAME);
//CLASSES
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
print(" ");
print("[+] SERVER ONLINE!");
djson_GameModeInit();
return 1;
}
COMMAND:changeservername(playerid, params[]) {
new
NewServerName[64],
string[128],
AuthCode[128];
if(PVar[playerid][Authorization] <= 2) return AuthError(playerid, 3);
if(sscanf(params, "s[64]d", NewServerName, AuthCode)) {
SendClientMessage(playerid, -1, "{EBA613}USAGE: {FFFFFF}/ChangeServerName [Server Name] [Auth. Code]");
SendClientMessage(playerid, -1, "{EBA613}FUNCTION: {FFFFFF}Temporarily changes the server name visable in the SA:MP Browser.");
return 1;
}
if(strlen(NewServerName) > 64) return ErrorMessage(playerid, "Server name must be below 64 characters!");
format(string, sizeof(string), "hostname %s", NewServerName);
SendRconCommand(string);
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}You have temporarily changed the server name to \"%s\".", NewServerName);
SendClientMessage(playerid, -1, string);
return 1;
}
COMMAND:strlen(playerid, params[]) {
new
CharLength[128],
string[128];
if(sscanf(params, "s[128]", CharLength)) {
SendClientMessage(playerid, -1, "{EBA613}USAGE: {FFFFFF}/StrLen [String]");
SendClientMessage(playerid, -1, "{EBA613}FUNCTION: {FFFFFF}Tells you how long the specified string is.");
return 1;
}
if(strlen(CharLength) > 128) return ErrorMessage(playerid, "String cannot be longer than 128 characters!");
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}The string length is %d characters.", strlen(CharLength));
SendClientMessage(playerid, -1, string);
return 1;
}
COMMAND:authorize(playerid, params[]) {
new
string[128],
Player,
AuthorizationLevel;
if(PVar[playerid][Authorization] <= 4) return AuthError(playerid, 5);
if(sscanf(params, "ud", Player, AuthorizationLevel)) {
SendClientMessage(playerid, -1, "{EBA613}USAGE: {FFFFFF}/Authorize [Player ID] [Auth. Level]");
SendClientMessage(playerid, -1, "{EBA613}FUNCTION: {FFFFFF}Authorizes the specified user to use new commands.");
return 1;
}
if(AuthorizationLevel > 5) return ErrorMessage(playerid, "Authorization Level cannot be higher than 5!");
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}You have granted %s an authorization level of %d.", GetTheirName(Player), AuthorizationLevel);
SendClientMessage(playerid, -1, string);
PVar[Player][Authorization] = AuthorizationLevel;
return 1;
}
COMMAND:giveweapon(playerid, params[]) {
new
string[128],
WeaponName[64],
Player,
WeaponAmmo;
if(PVar[playerid][Authorization] <= 2) return AuthError(playerid, 3);
if(sscanf(params, "us[64]I(100)", Player, WeaponName, WeaponAmmo)) {
SendClientMessage(playerid, -1, "{EBA613}USAGE: {FFFFFF}/GiveWeapon [Player ID] [Weapon Name] [Weapon Ammo (Optional - 100 default value)]");
SendClientMessage(playerid, -1, "{EBA613}FUNCTION: {FFFFFF}Gives the specified user a weapon with an amount of ammunition.");
return 1;
}
if(GetWeaponModelIDFromName(WeaponName) == -1) return ErrorMessage(playerid, "Invalid Weapon Name.");
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}You have been given a %s with %d ammunition.", WeaponName, WeaponAmmo);
SendClientMessage(playerid, -1, string);
GivePlayerWeapon(Player, GetWeaponModelIDFromName(WeaponName), WeaponAmmo);
return 1;
}
COMMAND:test(playerid, params[]) {
UsageMessage(playerid, "hello", "[Player ID]", "Says hello to the specified player.");
return 1;
}
public OnGameModeExit()
{
djson_GameModeExit();
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)
{
new
File[50];
format(File, sizeof(File), PFiles, GetTheirName(playerid));
if(fexist(File)) ShowPlayerDialog(playerid, LOGINDIALOG, DIALOG_STYLE_INPUT, "{0FA0D1}" cfg_SERVER_NAME" - Login", "{FFFFFF}Welcome back to " cfg_SERVER_NAME"!\nPlease enter your {36B816}password {FFFFFF}below to access your account", "Access", "Leave");
else {
ShowPlayerDialog(playerid, REGISTERDIALOG, DIALOG_STYLE_INPUT,"{0FA0D1}" cfg_SERVER_NAME" - Registration", "{FFFFFF}Welcome to " cfg_SERVER_NAME"!\nPlease enter a {36B816}password {FFFFFF}to create your account", "Create", "Leave");
}
if(PVar[playerid][Authorization] > 0) {
global_ConnectedAdmins++;
}
AddMapIconFromFile(ICON_FILE_NAME);
global_ConnectedPlayers++;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(ServerHasJustBeenRestarted == 1) {
return 1;
}
else
{
new File[50]; format(File, sizeof(File), PFiles, GetTheirName(playerid));
if(PlayerIsLoggedIn[playerid] == 1)
{
djSetInt (File, "Kills", PVar[playerid][Kills]);
djSetInt (File, "Deaths", PVar[playerid][Deaths]);
djSetInt (File, "Authorization", PVar[playerid][Authorization]);
djSetInt (File, "Money", PVar[playerid][Cash]);
djSetInt (File, "VIPLevel", PVar[playerid][VIPLevel]);
printf("[SAVE] %s has been saved.", GetTheirName(playerid));
}
}
if(PVar[playerid][Authorization] > 0) {
global_ConnectedAdmins--;
}
global_ConnectedPlayers--;
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 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[])
{
new File[50];
format(File, sizeof(File), PFiles, GetTheirName(playerid));
switch(dialogid)
{
case LOGINDIALOG:
{
if(response)
{
if(strlen(inputtext) == 0)
{
return ShowPlayerDialog(playerid, LOGINDIALOG, DIALOG_STYLE_INPUT, "{0FA0D1}"cfg_SERVER_NAME" - {FFFFFF}Login", "{FFFFFF}Welcome back to" cfg_SERVER_NAME"!\nPlease enter your {36B816}password {FFFFFF}below to access your account", "Access", "Leave");
}
if(strcmp(inputtext, dj(File, "Password", 50), true) == 0)
{
PVar[playerid][Kills] = djInt (File, "Kills");
PVar[playerid][Deaths] = djInt (File, "Deaths");
PVar[playerid][Authorization] = djInt (File, "Authorization");
PVar[playerid][Cash] = djInt (File, "Money");
PVar[playerid][VIPLevel] = djInt (File, "VIPLevel");
printf("[LOAD] %s has accessed their file.", GetTheirName(playerid));
PlayerIsLoggedIn[playerid] = 1;
}
else return ShowPlayerDialog(playerid, LOGINDIALOG, DIALOG_STYLE_INPUT, "{0FA0D1}"cfg_SERVER_NAME" - {FFFFFF}Login", "{FFFFFF}Welcome back to" cfg_SERVER_NAME"!\nPlease enter your {36B816}password {FFFFFF}below to access your account", "Access", "Leave");
}
else Kick(playerid);
}
case REGISTERDIALOG:
{
if(response)
{
if(strlen(inputtext) == 0)
{
return ShowPlayerDialog(playerid, REGISTERDIALOG, DIALOG_STYLE_INPUT, "{0FA0D1}"cfg_SERVER_NAME" - {FFFFFF}Register", "{FFFFFF}Welcome to" cfg_SERVER_NAME"!\nPlease enter a {36B816}password {FFFFFF}to create your account", "Create", "Leave");
}
djCreateFile(File);
djSet (File, "Password", inputtext);
djSetInt (File, "Kills", 0);
djSetInt (File, "Deaths", 0);
djSetInt (File, "Authorization", 0);
djSetInt (File, "Money", 50);
djSetInt (File, "VIPLevel", 0);
djCommit(File);
printf("[CREATE] %s has created their file.", GetTheirName(playerid));
PlayerIsLoggedIn[playerid] = 1;
}
else Kick(playerid);
}
/*case 5: //Authorize Dialog
{
if(response)
{
new
string[128];
if(strlen(inputtext) == 0) {
ShowPlayerDialog(playerid, 5, DIALOG_STYLE_INPUT, "Congratulations!", "You have recently been authorized, and need to set an Authorization Code.\nThis code can be up to 32 characters, and must be written down.", "Set!", "");
}
if(strlen(inputtext) > 32) {
ErrorMessage(playerid, "String cannot be longer than 32 characters!");
}
PVar[playerid][AuthorizationCode] = strval(inputtext);
printf("[+] %s has entered their authorization code. (%s)", GetTheirName(playerid), strval(inputtext));
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}You have set your authorization code to \"%s\". WRITE THIS DOWN!", strval(inputtext));
SendClientMessage(playerid, -1, string);
}
}*/
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
stock AddMapIconFromFile(DFileName[])
{
if(!fexist(DFileName)) return 0;
new File:MapFile, MType, Float:MX, Float:MY, Float:MZ, MColor, Line[128];
MapFile = fopen(DFileName, io_read);
while(fread(MapFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "fffii", MX, MY, MZ, MType, MColor);
CreateDynamicMapIcon(MX, MY, MZ, MType, MColor, -1, -1, -1, 100.0);
}
fclose(MapFile);
return 1;
}
stock AddMapIconToFile(DFileName[], Float:MX, Float:MY, Float:MZ, MType, MColor)
{
new File:MapFile, Line[128];
format(Line, sizeof(Line), "%f %f %f %i %i\r\n", MX, MY, MZ, MType, MColor);
MapFile = fopen(DFileName, io_append);
fwrite(MapFile, Line);
fclose(MapFile);
return 1;
}
stock AddVehiclesFromFile(DFileName[])
{
if(!fexist(DFileName)) return 0;
new File:VehicleFile, vModel, Float:VX, Float:VY, Float:VZ, Float:VA, vTotal, vColor1, vColor2, Line[128];
VehicleFile = fopen(DFileName, io_read);
while(fread(VehicleFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "ffffiii", VX, VY, VZ, VA, vModel, vColor1, vColor2);
AddStaticVehicleEx(vModel, VX, VY, VZ, VA, vColor1, vColor2, (30*60));
vTotal++;
}
fclose(VehicleFile);
return vTotal;
}
stock AddVehicleToFile(DFileName[], Float:VX, Float:VY, Float:VZ, Float:VA, vModel, vColor1, vColor2)
{
new File:VehicleFile, Line[128];
format(Line, sizeof(Line), "%f %f %f %f %i %i %i\r\n", VX, VY, VZ, VA, vModel, vColor1, vColor2);
VehicleFile = fopen(DFileName, io_append);
fwrite(VehicleFile, Line);
fclose(VehicleFile);
return 1;
}
stock AddPickupFromFile(DFileName[])
{
if(!fexist(DFileName)) return 0;
new File:PickupFile, PType, PModel, Float:PX, Float:PY, Float:PZ, pTotal, Line[128];
PickupFile = fopen(DFileName, io_read);
while(fread(PickupFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "fffii", PX, PY, PZ, PModel, PType);
CreateDynamicPickup(PModel, PType, PX, PY, PZ, -1, -1, -1, 100.0);
pTotal++;
}
fclose(PickupFile);
return pTotal;
}
stock AddPickupToFile(DFileName[], Float:PX, Float:PY, Float:PZ, PModel, PType)
{
new File:PickupFile, Line[128];
format(Line, sizeof(Line), "%f %f %f %i %i\r\n", PX, PY, PZ, PModel, PType);
PickupFile = fopen(DFileName, io_append);
fwrite(PickupFile, Line);
fclose(PickupFile);
return 1;
}
stock AddLabelsFromFile(LFileName[])
{
if(!fexist(LFileName)) return 0;
new File:LFile, Line[128], LabelInfo[128], Float:LX, Float:LY, Float:LZ, lTotal = 0;
LFile = fopen(LFileName, io_read);
while(fread(LFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "p<,>s[128]fff", LabelInfo,LX,LY,LZ);
CreateDynamic3DTextLabel(LabelInfo, 0xFFFFFFFF, LX, LY, LZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
lTotal++;
}
fclose(LFile);
return lTotal;
}
stock AddLabelToFile(LFileName[], LabelInfo[], Float:LX, Float:LY, Float:LZ)
{
new File:LFile, Line[128];
format(Line, sizeof(Line), "%s,%.2f,%.2f,%.2f\r\n",LabelInfo, LX, LY, LZ);
LFile = fopen(LFileName, io_append);
fwrite(LFile, Line);
fclose(LFile);
return 1;
}
GetWeaponModelIDFromName(wname[])
{
for(new i = 0; i < 48; i++) {
if (i == 19 || i == 20 || i == 21) continue;
if (strfind(aWeaponNames[i], wname, true) != -1) {
return i;
}
}
return -1;
}
stock GetTheirName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
stock ErrorMessage(Player, Message[])
{
new
string[128];
format(string, sizeof(string), "{EB1313}ERROR: {FFFFFF}%s", Message);
return SendClientMessage(Player, -1, string);
}
stock SuccessMessage(Player, Message[])
{
new
string[128];
format(string, sizeof(string), "{60BD09}SUCCESS: {FFFFFF}%s", Message);
return SendClientMessage(Player, -1, string);
}
stock IsOnAdminDuty(playerid)
{
if(OnAdministratorDuty[playerid] == 1) return 1;
else return 0;
}
stock UsageMessage(playerid, CommandName[], CommandUsage[], FunctionDescription[])
{
new
string[128];
format(string, sizeof(string), "{EBA613}USAGE: {FFFFFF}/%s %s", CommandName, CommandUsage);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "{EBA613}FUNCTION: {FFFFFF}%s", FunctionDescription);
SendClientMessage(playerid, -1, string);
return 1;
}
stock AuthError(Player, Level)
{
new
string[128];
format(string, sizeof(string), "{EB1313}ERROR: {FFFFFF}You are not authorized to use this command! (Needed Authorization: Level {EB1313}%d{FFFFFF})", Level);
return SendClientMessage(Player, -1, string);
}
stock ClearChat(playerid) //20 blank messages.
{
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
SendClientMessage(playerid, c_white, " ");
return 1;
}