17.05.2015, 22:52
Hi there,
I'm aware that TogglePlayerSpectating calls OnPlayerSpawn, it's causing me a bit of a headache working out what I can do here, because it seems to be getting my health wrong and knocking me unconscious in the game.
I'm using it to remove the *SPAWN* button, I'm using TogglePlayerSpectating(playerid, 1) on OnPlayerConnect and trying to remove it when spawning the player.
As TogglePlayerSpectating calls OnPlayerSpawn and I'm using SpawnPlayer, I'm getting confused, and again, it's causing the character to get the wrong health or the sorts. I'm not sure why.
KNOCKOUT SYSTEM UNDER ONPLAYERUPDATE.
LOGIN DIALOG.
Could someone tell me where I should use TogglePlayerSpectating(playerid, 0) and it should not affect that system?
I'm assuming it should be under the dialog.
Thanks,
Grant.
I'm aware that TogglePlayerSpectating calls OnPlayerSpawn, it's causing me a bit of a headache working out what I can do here, because it seems to be getting my health wrong and knocking me unconscious in the game.
I'm using it to remove the *SPAWN* button, I'm using TogglePlayerSpectating(playerid, 1) on OnPlayerConnect and trying to remove it when spawning the player.
As TogglePlayerSpectating calls OnPlayerSpawn and I'm using SpawnPlayer, I'm getting confused, and again, it's causing the character to get the wrong health or the sorts. I'm not sure why.
KNOCKOUT SYSTEM UNDER ONPLAYERUPDATE.
pawn Code:
new Float:health;
GetPlayerHealth(playerid,health);
if(LoggedIn[playerid] == 1 && health <= 40 && KnockedOut[playerid] == 0)
{
KnockedOut[playerid] = 1;
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0,1);
TextDrawShowForPlayer(playerid,BFText);
new string[128];
format(string, sizeof(string), "* %s has lost consciousness due to their injuries *", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
}
pawn Code:
if(dialogid == DIALOG_LOGIN)
{
if(response == 0)
{
Kick(playerid);
}
else
{
new query[512], password[256];
new buf[129];
WP_Hash(buf, sizeof(buf), inputtext);
format(query, sizeof(query), "SELECT `Password` FROM `accounts` WHERE id = %d", PlayerSQLID[playerid]);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(password);
mysql_free_result();
new string[300];
format(string, sizeof(string), "Welcome to %s\n\nYou entered a wrong password, please try again:", HOSTNAME);
if(isnull(inputtext))return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Please retry your password", string, "Login", "Leave");
if(strcmp(password, buf, false) == 0)
{
SetPlayerHealth(playerid, 100);
LoggedIn[playerid] = 1;
LoadAccount(playerid);
new skin = GetPlayerSkinEx(playerid);
SetSpawnInfo(playerid, 0, skin,-2802.0896,1183.8734,20.2734,170.2243, 0,0,0,0,0,0);
PlayerBanned[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Banned", "accounts");
SpawnPlayer(playerid);
SetCameraBehindPlayer(playerid);
GivePlayerWeaponEx(playerid);
AutoSaveTimer[playerid] = SetTimerEx("WeaponSaveTimer", 60000, true,"i", playerid);
Streamer_Update(playerid);
new playerip[16];
for(new h = 0; h < MAX_HOUSES; h++)
{
if(HouseOwner[h] == PlayerSQLID[playerid] && BreachedOff[h] == 1)
{
format(string, sizeof(string), ""COL_RED"ALERT"COL_WHITE": Your owned property, %s, detected a perimeter breach when you were offline.", HouseName[h]);
SendClientMessage(playerid, COLOUR_WHITE, string);
BreachedOff[h] = 0;
MySQL_SetInteger(h, "BreachedOff", 0, "houses");
}
}
format(query, sizeof(query), "SELECT * FROM `bans` WHERE `ip` = '%s'", playerip);
mysql_query(query);
mysql_store_result();
if(WasDead[playerid] == 1)
{
new string2[128];
format(string2, sizeof(string2), "You have been automatically admin jailed for 60 minutes, Reason: logging to avoid death.");
SendClientMessage(playerid, COLOUR_LIGHTBLUE, string2);
format(string2, sizeof(string2), "[Auto-Jail]%s has been admin jailed [Reason: Logging to avoid death.]", GetNameEx(playerid));
SendClientMessageToAll(COLOUR_LIGHTBLUE, string2);
AdminJail[playerid] += 60;
SetPlayerPos(playerid, 264.58, 77.38, 1001.04);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 0);
MySQL_SetInteger(PlayerSQLID[playerid], "AdminJail",AdminJail[playerid], "accounts");
MySQL_SetInteger(PlayerSQLID[playerid], "WasDead", 0, "accounts");
WasDead[playerid] = 0;
}
if(AdminJail[playerid] >= 1)
{
new string2[128];
format(string2, sizeof(string2), "You have %d minute(s) left in Admin Jail.", AdminJail[playerid]);
SendClientMessage(playerid, COLOUR_GREY, string2);
SetPlayerPos(playerid, 264.58, 77.38, 1001.04);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 0);
}
if(Jail[playerid] >= 1)
{
SetPlayerPos(playerid, 319.5663,311.9558,999.1484);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, 0);
new string2[128];
format(string2, sizeof(string2), "You still have %d minute(s) of jail time to serve.", Jail[playerid]);
SendClientMessage(playerid, COLOUR_GREY, string2);
}
new param1[64], param2[64];
if(Faction[playerid] == 0) {
param1 = "Civilian (0)";
param2 = "N/A";
}
else {
strcpy(param1, FactionName[Faction[playerid]], sizeof(param1));
switch(FRank[playerid]) { // strcpy(dest, source, length);
case 1: strcpy(param2, FactionRank1[Faction[playerid]], sizeof(param2));
case 2: strcpy(param2, FactionRank2[Faction[playerid]], sizeof(param2));
case 3: strcpy(param2, FactionRank3[Faction[playerid]], sizeof(param2));
case 4: strcpy(param2, FactionRank4[Faction[playerid]], sizeof(param2));
case 5: strcpy(param2, FactionRank5[Faction[playerid]], sizeof(param2));
case 6: strcpy(param2, FactionRank6[Faction[playerid]], sizeof(param2));
case 7: strcpy(param2, FactionRank7[Faction[playerid]], sizeof(param2));
}
}
format(string, sizeof(string), "Welcome back to San Fierro Roleplay, %s. Level: %d | Money: $%s | Admin Level: %d | Donator Level %d |", GetNameEx(playerid), PlayerLevel[playerid],AddCommas(PlayerMoney[playerid]), AdminLevel[playerid], Donator[playerid]);
SendClientMessage(playerid, 0xFFD99FFF, string);
format(string, sizeof(string), "Faction Name: %s | Faction Rank: %s (%d) | Rank Pay: $%s |", param1, param2, FRank[playerid], AddCommas(GetRankPay(playerid)));
SendClientMessage(playerid, 0xFFD99FFF, string);
format(string, sizeof(string), "Misc: Total Time Played (minutes): %d | Total House Break Ins: %d | Total Vehicle Break Ins: %d | Total Hotwires %d | Kills %d | Deaths %d |", TotalTime[playerid], TotalHouseBI[playerid], TotalVehBI[playerid], TotalHotwires[playerid], PlayerKills[playerid], PlayerDeaths[playerid]);
SendClientMessage(playerid,0xFFD99FFF, string);
format(string, sizeof(string), "Skills: Thief Level: %d | Crafting Level: %d", ThiefLevel[playerid], CraftingLevel[playerid]);
SendClientMessage(playerid,0xFFD99FFF, string);
}
else
{
format(string, sizeof(string), "Welcome to %s\n\nYou entered a wrong password, please try again:", HOSTNAME);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Please retry your password", string, "Login", "Leave");
}
}
}
I'm assuming it should be under the dialog.
Thanks,
Grant.