MySQL value isn't changing when it says to in the script. -
Stephano - 02.03.2013
I can't seem to find the cause of this problem that I'm trying to fix. Basically, there's suppose to be a point in the script where a "race selection" would come up, asking you what race you want to be. I have 3 races, so I match up the races to a number. Human is 1, Ghoul is 2, and Feral Ghoul is 3. Once you choose a race, it should change the MySQL value for "race". This is where the problem happens, it doesn't change the value.
This is when they choose an option for the race selection.
Код:
{
if(!response)Kick(playerid);
else
{
switch(listitem)
{
case 0:
{
Player[playerid][Race] = 1;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Human.");
AfterLogin(playerid);
}
case 1:
{
Player[playerid][Race] = 2;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Ghoul.");
AfterLogin(playerid);
}
case 2:
{
Player[playerid][Race] = 3;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Feral Ghoul.");
AfterLogin(playerid);
}
}
}
}
This is the dialog response to registering an account. (not sure if this helps)
Код:
{
if(!response)Kick(playerid);
else
{
if(!strlen(inputtext))ShowPlayerDialog(playerid, 0, DIALOG_STYLE_PASSWORD, "Register", "Register by entering a password below:", "Register", "Exit");
new query[256];
format(query, sizeof(query), "INSERT INTO `accounts` (`name`, `password`) VALUES ('%s', '%s')", pName(playerid), inputtext);
mysql_query(query);
DefaultRegisterVariables(playerid);
ShowPlayerDialog(playerid, 10, DIALOG_STYLE_LIST, "Race Selection", "Human\nGhoul\nFeral Ghoul", "Choose", "Exit");
}
}
Sorry about indentation, it's all correct on the script, just doesn't come out right on the forums. Anyone know how to fix this?
Re: MySQL value isn't changing when it says to in the script. -
[MG]Dimi - 02.03.2013
You don't have anywhere code to update MySQL Database.
pawn Код:
{
if(!response)Kick(playerid);
else
{
switch(listitem)
{
case 0:
{
Player[playerid][Race] = 1;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Human.");
AfterLogin(playerid);
}
case 1:
{
Player[playerid][Race] = 2;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Ghoul.");
AfterLogin(playerid);
}
case 2:
{
Player[playerid][Race] = 3;
SendClientMessage(playerid, WHITE, "You have chosen to live as a Feral Ghoul.");
AfterLogin(playerid);
}
}
new Query[128];
format(Query,128,"UPDATE `accounts` SET `race` = %d WHERE `username` = '%s' LIMIT 1",Player[playerid][Race], pName(playerid));
mysql_query(Query);
}
}
TIPS:
1) For better security hash passwords
2) Use to show codes with better indentation.
Re: MySQL value isn't changing when it says to in the script. -
Stephano - 02.03.2013
It set it now, but now another problem has risen.
Код:
public OnPlayerRequestClass(playerid, classid)
{
if(Player[playerid][Race] == 1)
{
SetSpawnInfo(playerid, 0, Player[playerid][Skin], 468.8824, 881.1055, -29.1138, 277.1616, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else if(Player[playerid][Race] == 2)
{
SetSpawnInfo(playerid, 0, 78, 214.7090,1902.7179,17.6406,178.9659, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else if(Player[playerid][Race] == 3)
{
SetSpawnInfo(playerid, 0, 162, 274.3081,1412.3754,10.4440,267.3267, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
if(Player[playerid][Radiation] < 9)Player[playerid][Radiation] = 9;
return 1;
}
It doesn't use SetSpawnInfo and it crashes when I try spawning.
Re: MySQL value isn't changing when it says to in the script. -
Stephano - 03.03.2013
Fixed.