16.02.2014, 21:07
When i save a faction it does like this
HasFaction = 1
FactionName = RAF
FactionTag = RAF
[Player's Data]
Password = 988EEC2A02039635B6836CE3700EDA7DB441BE8B4675492A53 C20A70CDA2A75C9852FB52DDFF2A0F51BB4A3E1EA46A228B36 542B6E9F439382806E3AA80F3260
AdminLevel = 5
VIPLevel = 0
Money = 275930
Scores = 210
Kills = 200
Deaths = 174
Banned = 0
FactionName =
FactionTag =
HasFaction = 0
here is my code:
HasFaction = 1
FactionName = RAF
FactionTag = RAF
[Player's Data]
Password = 988EEC2A02039635B6836CE3700EDA7DB441BE8B4675492A53 C20A70CDA2A75C9852FB52DDFF2A0F51BB4A3E1EA46A228B36 542B6E9F439382806E3AA80F3260
AdminLevel = 5
VIPLevel = 0
Money = 275930
Scores = 210
Kills = 200
Deaths = 174
Banned = 0
FactionName =
FactionTag =
HasFaction = 0
here is my code:
pawn Код:
CMD:createfaction(playerid, params[])
{
if(pInfo[playerid][Adminlevel] >= 5)
{
new string[128], FactionName[128], FactionTag[128];
if(FactionName[playerid] > 1 || FactionTag[playerid] > 1)
{
SendClientMessage(playerid, COLOR_RED, "You can't create another faction.");
return 1;
}
if(FactionCreated[playerid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You can't create another faction.");
return 1;
}
if(sscanf(params, "s[128]s[128]", FactionTag, FactionName))
{
SendClientMessage(playerid, COLOR_RED, "Usage: /createfaction <faction tag> <faction name>.");
return 1;
}
strcat(Faction1[playerid], FactionTag);
strcat(Faction[playerid], FactionName);
if(strlen(Faction1[playerid]) > 4)
{
strdel(Faction[playerid], 0, 128);
strdel(Faction1[playerid], 0, 128);
SendClientMessage(playerid, COLOR_RED, "You have exceeded the max characters in the Faction Tag parameters.");
return 1;
}
if(strlen(Faction[playerid]) > 20)
{
strdel(Faction[playerid], 0, 128);
strdel(Faction1[playerid], 0, 128);
SendClientMessage(playerid, COLOR_RED, "You have exceeded the max characters in the Faction Name parameters.");
return 1;
}
format(string, sizeof (string), "%s (%d) has created a faction named %s ([%s]).", GetName(playerid), playerid, Faction[playerid], Faction1[playerid]);
SendClientMessageToAll(COLOR_RED, string);
FactionCreated[playerid] = 1;
pInfo[playerid][HasFaction] = 1;
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_WriteInt(file, "HasFaction",pInfo[playerid][HasFaction]);
INI_WriteString(file, "FactionName",Faction[playerid]);
INI_WriteString(file, "FactionTag",Faction1[playerid]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
}
return 1;
}
pawn Код:
if(dialogid == dregister) //If dialog id is a register dialog
{//then
if(!response) return Kick(playerid); //If they clicked the second button "Quit", we will kick them.
if(response) //if they clicked the first button "Register"
{//then
if(!strlen(inputtext)) //If they didn't enter any password
{// then we will tell to them to enter the password to register
ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
//If they have entered a correct password for his/her account...
new hashpass[129]; //Now we will create a new variable to hash his/her password
WP_Hash(hashpass,sizeof(hashpass),inputtext);//We will use whirlpool to hash their inputted text
new INI:file = INI_Open(Path(playerid)); // we will open a new file for them to save their account inside of Scriptfiles/Users folder
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteString(file,"Password",hashpass);//This will write a hashed password into user's account
INI_WriteInt(file,"AdminLevel",0); //Write an integer inside of user's account called "AdminLevel". We will set his level to 0 after he registered.
INI_WriteInt(file,"VIPLevel",0);//As explained above
INI_WriteInt(file,"Money",0);//Write an integer inside of user's account called "Money". We will set their money to 0 after he registered
INI_WriteInt(file,"Scores",0);//Write an integer inside of user's account called "Scores". We will set their score to 0 after he registered
INI_WriteInt(file,"Kills",0);//As explained above
INI_WriteInt(file,"Deaths",0);//As explained above
INI_WriteInt(file,"Banned",0);
INI_WriteInt(file,"HasFaction",0);
INI_WriteString(file, "FactionName","None");
INI_WriteString(file, "FactionTag","None");
INI_Close(file);//Now after we've done saving their data, we now need to close the file
SendClientMessage(playerid,-1,"You have been successfully registered");//Tell to them that they have successfully registered a new account
SetPVarInt(playerid, "NoNPCSpawn", 1);
return 1;
}
pawn Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_Int("Money",pInfo[playerid][Money]); //As explained above
INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Int("Banned",pInfo[playerid][Banned]);
INI_Int("HasFaction",pInfo[playerid][HasFaction]);
INI_String("FactionName",Faction[playerid], 128);
INI_String("FactionTag",Faction1[playerid], 128);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYER_NAME], string[128 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(string, sizeof(string), "{FF9915}%s has {FFFFFF}left {FF9915}Golden Warfare Call of Duty Server. (Timeout)", pname);
case 1: format(string, sizeof(string), "{FF9915}%s has {FFFFFF}left {FF9915}Golden Warfare Call of Duty Server. (Leaving)", pname);
case 2: format(string, sizeof(string), "{FF9915}%s has {FFFFFF}left {FF9915}Golden Warfare Call of Duty Server. (Kicked/Banned)", pname);
}
SendClientMessageToAll(0xAAAAAAAA, string);
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
INI_WriteInt(file,"Banned",pInfo[playerid][Banned]);
INI_WriteInt(file,"HasFaction",pInfo[playerid][HasFaction]);
INI_WriteString(file, "FactionName",Faction[playerid]);
INI_WriteString(file, "FactionTag",Faction1[playerid]);
INI_Close(file);//Now after we've done saving their data, we now need to close the file
pInfo[playerid][Last] = -1;
pInfo[playerid][NoPM] = 0;
pInfo[playerid][HasFaction] = 0;
Assault[playerid] =0;
Sniper[playerid] =0;
Engineer[playerid] =0;
Pilot[playerid] =0;
Gunner[playerid] =0;
onduty[playerid] =0;
Killed[playerid] =0;
return 1;
}