28.09.2010, 23:00
If I log in before spawning, then one of the checks will not run. If I spawn, then login, there is no conflict. I've stared at the code for about 3 hours, trying various possibilities to which they have all failed.
OnPlayerSpawn code:
The login command:
Dialog response code for Login
Every thing loads correctly from the file. At first, I thought it was a PVar screw up of some how, but after clearing all variables and a lot of debugging, I found that wasn't the problem. I then checked if it was only that if statement that didn't check, and I was right. The following code printed.
It was placed under the OnPlayerSpawn. I checked and it printed correctly, depending on which value I set X to.
So the only thing I can figure now is that there is something with that if statement. I honestly have no idea what COULD be wrong, but I might be overlooking something.
Any suggestions are welcomed, and very much appreciated.
OnPlayerSpawn code:
pawn Код:
if(iRoundStarted == false)
{
SendClientMessage(playerid, COLOR_NOTICE, "[NOTICE]: The current round has not started yet, please wait for it to do so.");
TogglePlayerSpectating(playerid, true);
PlayerSpectatePlayer(playerid, playerid);
return 1;
}
// -- Code will stop here -- //
if(GetPVarInt(playerid, "NextVehicle") != 0)
{
SetPVarInt(playerid, "Vehicle", CreateVehicle(GetPVarInt(playerid, "NextVehicle"), SumoSpawns[iMap][playerid][0], SumoSpawns[iMap][playerid][1], SumoSpawns[iMap][playerid][2], SumoSpawns[iMap][playerid][3], -1, -1, 10000));
SetPVarInt(playerid, "NextVehicle", 0);
}
else
{
SetPVarInt(playerid, "Vehicle", CreateVehicle(SumoModels[random(sizeof(SumoModels))], SumoSpawns[iMap][playerid][0], SumoSpawns[iMap][playerid][1], SumoSpawns[iMap][playerid][2], SumoSpawns[iMap][playerid][3], -1, -1, 10000));
}
SetPVarInt(playerid, "Spawned", 1);
SetPlayerColor(playerid, COLOR_GREEN);
SetPlayerScore(playerid, 0);
PutPlayerInVehicle(playerid, GetPVarInt(playerid, "Vehicle"), 0);
return 1;
pawn Код:
if(!strcmp(cmdtext, "/login", true))
{
if(GetPVarInt(playerid, "Logged") == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You are already logged in.");
format(file, sizeof(file), "Sumo/%s.ini", PlayerName(playerid));
if(!fexist(file)) SendClientMessage(playerid, COLOR_RED, "Error: Your username is not registered. Use (\"/register\") to register.");
else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Please insert your password below and click \"Submit\".\n\nTo cancel, click \"Cancel\"", "Submit", "Cancel");
return 1;
}
pawn Код:
case DIALOG_LOGIN:
{
format(file, sizeof(file), "Sumo/%s.ini", PlayerName(playerid));
open_file = fopen(file, io_read);
fread(open_file, str);
new key[50];
key = ini_GetKey(str);
if(!strcmp(key, "Password", true))
{
new p[50];
p = ini_GetValue(str);
strmid(Pass[playerid], p, 0, strlen(p)-2, 255);
if(!strcmp(Pass[playerid], encrypt(inputtext), true))
{
while(fread(open_file, str))
{
key = ini_GetKey(str);
if(!strcmp(key, "Money", true))
{
GivePlayerMoney(playerid, strval(ini_GetValue(str)));
}
}
SendClientMessage(playerid, COLOR_GREEN, "Successfully logged in.");
SetPVarInt(playerid, "Logged", 1);
fclose(open_file);
return 1;
}
SendClientMessage(playerid, COLOR_RED, "Error: Incorrect password.");
}
fclose(open_file);
}
pawn Код:
new x = 3;
if(x == 3) { print("hi"); }
else { print("bye"); }
So the only thing I can figure now is that there is something with that if statement. I honestly have no idea what COULD be wrong, but I might be overlooking something.
Any suggestions are welcomed, and very much appreciated.