24.09.2012, 09:13
First of all, like ****** said, you mixed up strings with integers. For example:
Next up, same thing, mixed strings with integer:
That's for the HOUSE. Now, let's move on to the player load. Exactly the same thing, mixing strings with integers:
Next up, dialogs: In the REGISTER dialog I don't even see why you check if player variable 'Member' is smaller than 1. It's obvious that when you register, you won't have Member more than 0. So, no need for that.
You need another ParseFile for the password, which I can't find in your post. Here is an example:
// SOmewhere in your script, to load the password
pawn Код:
for(new i = 0; i < MAX_HOUSES; i++)
{
new string[30];
format(string,sizeof(string),HOUSEPATH,i);
if(fexist(string))
{
print("File exists."); //Debug
INI_ParseFile(string, "LoadHouse_%s", .bExtra = true, .extra = i); // %s means loading string and your extra parameter is i, which is integer. Change %s to %i
if(House[i][Owned] == 0)
{
House[i][Pickup] = CreateDynamicPickup(1272, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
print("Pickup Created"); //Debug
}
else
{
House[i][Pickup] = CreateDynamicPickup(1273, 1, House[i][PosX], House[i][PosY], House[i][PosZ]);
print("Pickup Created Owned"); //Debug
}
format(string,sizeof(string),"House: %s\nOwner: %s\nID: %d",House[i][Name],House[i][OwnerName],i);
House[i][Label] = CreateDynamic3DTextLabel(string, green, House[i][PosX], House[i][PosY], House[i][PosZ], 100.00);
print("Text label created"); //Debug
continue;
}
continue;
}
Next up, same thing, mixed strings with integer:
pawn Код:
forward LoadHouse_data(houseid,name[],value[]);
public LoadHouse_data(houseid,name[],value[])
{
//INI_Int("HouseName",House[houseid][Name]); // Change INI_Int with INI_String since Name is a string
INI_String("HouseName",House[houseid][Name], 64);
printf("House id %d Name loaded", houseid); //Debug
INI_Float("X",House[houseid][PosX]);
INI_Float("Y",House[houseid][PosY]);
INI_Float("Z",House[houseid][PosZ]);
INI_Int("Owned",House[houseid][Owned]);
//INI_Int("OwnerName",House[houseid][OwnerName]); Same here, used INI_Int instead of String
//INI_String("OwnerName",House[houseid][Ownername], 24);
INI_Int("Key1",House[houseid][Key1]);
INI_Int("Key2",House[houseid][Key2]);
INI_Int("Key3",House[houseid][Key3]);
return 1;
}
That's for the HOUSE. Now, let's move on to the player load. Exactly the same thing, mixing strings with integers:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
//INI_Int("Password",Player[playerid][Password]);
INI_String("Password",Player[playerid][Password], 129); // Change 100 with your Password string length
print("Password Loaded"); //Debug
INI_Int("Cash",Player[playerid][Cash]);
print("Cash Loaded"); //Debug
INI_Int("Admin",Player[playerid][Admin]);
print("Admin Loaded"); //Debug
INI_Int("Kills",Player[playerid][Kills]);
INI_Int("Deaths",Player[playerid][Deaths]);
INI_Int("VIP",Player[playerid][pVip]);
INI_Int("Score",Player[playerid][Score]);
INI_Int("Helper",Player[playerid][Helper]);
INI_Int("Builder",Player[playerid][Builder]);
INI_Int("Member",Player[playerid][Member]);
print("Member Loaded"); //Debug
INI_Int("BanReason",Player[playerid][BanReason]);
INI_Int("LastLogin",Player[playerid][LastLogin]);
INI_Int("Caged",Player[playerid][Caged]);
INI_Int("Muted",Player[playerid][Muted]);
INI_Int("Banned",Player[playerid][Banned]);
print("Ban Loaded"); //Debug
return 1;
}
You need another ParseFile for the password, which I can't find in your post. Here is an example:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case REGISTER:
{
if(!response)
{
new string[105];
SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
SendClientMessageToAll(red, string);
return Kick(playerid);
}
if(response)
{
if(strfind(pName(playerid), "[AWP]", true) != -1)
{
if(Player[playerid][Member] < 1)
{
new string[105];
SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
SendClientMessageToAll(red, string);
return Kick(playerid);
}
}
new buf[129];
if(!strlen(inputtext) || strlen(inputtext) < 4 || strlen(inputtext) > 24) return ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_INPUT, "{FF0000}INVALID PASSWORD","{FF0000}You Have Entered An Invalid Password.\n{00FF00}Please Note: Passwords Must Be At Least 4 To 24 Characters Long.\n{00F0F0}Please Enter Your Desired Password Below:","Accept","Leave");
INI_ParseFile(UserPath(playerid), "LoadUserPass", false, true, playerid);
WP_Hash(buf, sizeof(buf), inputtext);
printf("String %s Created", buf); //Debug
//new INI:File = INI_Open(UserPath(playerid));
// printf("User File Opened"); //Debug
// INI_WriteString(File,"Password",buf);
// printf("String %s Saved to User File",buf); //Debug
// INI_Close(File);
// printf("File Closed."); //Debug
if(strcmp(WP_Hash, Player[playerid][Password], false))
{
// Here what you want to do if password is wrong.
}
else INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); // You load the player data
}
}
case LOGIN:
{
new string[130];
if(!response)
{
SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Register And Login Before Playing.");
format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Register/Login **",pName(playerid));
SendClientMessageToAll(red, string);
return Kick(playerid);
}
if(response)
{
new buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
if(strcmp(Player[playerid][Password], buf, false) == 0)
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
if(strfind(pName(playerid), "[AWP]", true) != -1)
{
if(Player[playerid][Member] < 1)
{
SendClientMessage(playerid, red, "Only Authorised AWP Clan Members Can Wear The [AWP] Tag.");
SendClientMessage(playerid, orange, "If You Think You Are Receiving This Message In Error, Please Contact An AWP Clan Administrator.");
format(string,sizeof(string),"%s Has Been Kicked From The Server Automatically | Reason: Unauthorised [AWP] Tag");
SendClientMessageToAll(red, string);
return Kick(playerid);
}
}
if(Player[playerid][LastLogin] != 0)
{
format(string,sizeof(string),"You Last Logged In: %s. Welcome Back.",Player[playerid][LastLogin]);
SendClientMessage(playerid, yellow, string);
}
new string1[30];
new day, month, year, hour, minute, second;
getdate(year, month, day);
gettime(hour, minute, second);
format(string1,sizeof(string1),"%d/%d/%d | %d:%d:%d",day,month,year,hour,minute,second);
Player[playerid][LastLogin] = string1;
SetPlayerMoney(playerid, Player[playerid][Cash]);
SetPlayerScore(playerid, Player[playerid][Score]);
Player[playerid][LoggedIn] = 1;
SaveStats(playerid);
if(ServerInfo[BetaMode] == 1)
{
if(Player[playerid][Admin] == 0 && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, red, "ERROR: {FFFFFF}The Server Is Currently In BETA Mode. Once The Server's Map Name Is No Longer 'BETA', You Will Be Able To Join.");
SendClientMessage(playerid, orange, "Only Authorised BETA Testers, Administrators And RCON Administrators Can Access The Server During BETA Mode.");
return Kick(playerid);
}
}
SendClientMessage(playerid, green, "You Have Successfully Logged In And Your Current Stats Have Been Loaded.");
ShowPlayerDialog(playerid, RULES, DIALOG_STYLE_MSGBOX, "SERVER RULES", "This is {FF0000}just a test message {00FF00}that will later {0000FF}be replaced by {FFFF00}server rules.","Accept","Decline");
}
else
{
if(Player[playerid][LoginWarn] >= 2)
{
SendClientMessage(playerid, red, "You Have Been Kicked From The Server. You MUST Enter The Correct Password When Logging In.");
SendClientMessage(playerid, orange, "If You Have Forgotten Your Password, Please Contact An Administrator At: 'WWW.AWPGAMING.COM/FORUMS'");
format(string,sizeof(string),"** Player %s Has Been Kicked From The Server | Reason: Failed To Login **",pName(playerid));
Kick(playerid);
SendClientMessageToAll(red, string);
return 1;
}
Player[playerid][LoginWarn]++;
format(string,sizeof(string),"You Have Entered An Incorrect Password. You Have A Maximum Of 3 Attempts Before You Are Automatically Kicked. %d/3 Attempts Used.",Player[playerid][LoginWarn]);
SendClientMessage(playerid, red, string);
return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD,"{FF0000}INCORRECT PASSWORD","{FF0000}You Have Entered An Incorrect Password, Please Try Again, You Will Have 3 Attempts In Total Before Being Kicked.\n{00F0F0}Please Enter Your Current Password Below:","Accept","Leave");
}
return 1;
}
}
//Code continues
pawn Код:
forward LoadUserPass(playerid, name[], value[]);
public LoadUserPass(playerid, name[], value[])
{
if(!strcmp(name, "Password"))
INI_String("Password", Player[playerid][Password], 129;
}