This is when player die.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
new pname[256], deathquery[512], deathrow[512], deathfield[10][25], cash;
GetPlayerName(playerid, pname, sizeof (pname));
SendClientMessage(playerid, COLOR_LIGHTRED, "You almost died. \nSan Andreas Paramedic has heald you. \nPay: 300$");
format(deathquery, sizeof (deathquery), "SELECT * FROM players WHERE name = '%s'", pname);
mysql_query(deathquery);
mysql_store_result();
mysql_fetch_row(deathrow);
split(deathrow, deathfield, '|');
cash = PlayerInfo[playerid][Cash] - 300;
format(deathquery, sizeof (deathquery), "UPDATE players SET cash = %d WHERE name = '%s' ", cash, pname);
mysql_query(deathquery);
PlayerInfo[playerid][Cash] = cash;
OnPlayerDied(playerid);
return 0;
}
after that it call function OnPlayerDied()
pawn Код:
public OnPlayerDied(playerid) {
SetPlayerCameraPos(playerid, 1242.607421, 327.397186, 19.755510);
SetPlayerCameraLookAt(playerid, 1242.607421, 327.397186, 19.755510);
if (IsPlayerConnected(playerid)) {
SetPlayerHealth(playerid, 50.0);
if (GetPlayerWeapon(playerid) >= 0) {
ResetPlayerWeapons(playerid);
}
IsDeath[playerid] = 1;
SetTimer("spawn", 5000, false);
}
}
this function call function spawn which spawn player and set IsDeath[playerid] to 1
after that goes this
pawn Код:
public OnPlayerDisconnect(playerid, reason) {
IsPlayerAfk[playerid] = 0;
IsLogged[playerid] = 0;
IsDeath[playerid] = 0;
showspeedo[playerid] = 0;
gVirtualWorld[playerid] = 0;
PlayerFrozen[playerid] = 0;
IsPlayerAfk[playerid] = 0;
PlayerHealth[playerid] = 100;
PlayerArmour[playerid] = 0;
PlayerInfo[playerid][Cash] = 0;
gLastX[playerid] = 0;
gLastY[playerid] = 0;
gLastZ[playerid] = 0;
}
public OnPlayerSpawn(playerid) {
new name[256], queryspawn[512], rowspawn[512], fieldspawn[11][20];
new Float:spawnx, Float:spawny, Float:spawnz;
new hsfield[3][10];
GetPlayerName(playerid, name, sizeof (name));
if (IsLogged[playerid] == 0) {
SendClientMessage(playerid, COLOR_GRAD2, "SERVER: You have not logged in yet.");
return 1;
}
PlayerPlaySound(playerid, 1186, 0, 0, 0);
format(queryspawn, sizeof (queryspawn), "SELECT * FROM players WHERE name = '%s'", name);
mysql_query(queryspawn);
mysql_store_result();
if (mysql_num_rows() != 0) {
mysql_fetch_row(rowspawn);
split(rowspawn, fieldspawn, '|');
new FactionID[MAX_PLAYERS];
FactionID[playerid] = strval(fieldspawn[7]);
pSkinID[playerid] = strval(fieldspawn[4]);
if (PlayerInfo[playerid][Faction] != 0) {
new skinq[512], skinrow[512], skinf[3][20];
format(skinq, sizeof (skinq), "SELECT * FROM faction_skins WHERE faction = %d AND rank = %d", strval(fieldspawn[7]), strval(fieldspawn[9]));
mysql_query(skinq);
mysql_store_result();
mysql_fetch_row(skinrow);
split(skinrow, skinf, '|');
SetPlayerSkin(playerid, strval(skinf[0]));
pSkinID[playerid] = strval(skinf[0]);
}
new spawnq[512], spawnr[512], spawnfield[3][50];
format(spawnq, sizeof (spawnq), "SELECT * FROM spawn WHERE PlayerName = '%s'", name);
mysql_query(spawnq);
mysql_store_result();
mysql_fetch_row(spawnr);
split(spawnr, spawnfield, '|');
if (strval(spawnfield[1]) == 1) {
spawnx = 1242.607421;
spawny = 327.397186;
spawnz = 19.755510;
} else if (strval(spawnfield[1]) == 2) {
format(spawnq, sizeof (spawnq), "SELECT `px` , `py` , `pz` FROM `houses` WHERE owner = '%s'", name);
mysql_query(spawnq);
mysql_store_result();
mysql_fetch_row(spawnr);
split(spawnr, hsfield, '|');
spawnx = floatstr(hsfield[0]);
spawny = floatstr(hsfield[1]);
spawnz = floatstr(hsfield[2]);
} else if (strval(spawnfield[1]) == 3) {
format(spawnq, sizeof (spawnq), "SELECT `px` , `py` , `pz` FROM `factionhq` WHERE faction_id = %d", FactionID[playerid]);
mysql_query(spawnq);
mysql_store_result();
mysql_fetch_row(spawnr);
split(spawnr, hsfield, '|');
spawnx = floatstr(hsfield[0]);
spawny = floatstr(hsfield[1]);
spawnz = floatstr(hsfield[2]);
}
}
if (IsDeath[playerid] == 1) {
spawnx = 1242.607421;
spawny = 327.397186;
spawnz = 19.755510;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
SetPlayerSkin(playerid, pSkinID[playerid]);
SetPlayerPos(playerid, spawnx, spawny, spawnz);
IsDeath[playerid] = 0;
} else {
GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
SetPlayerSkin(playerid, pSkinID[playerid]);
SetPlayerPos(playerid, spawnx, spawny, spawnz);
return 1;
}
return 1;
}
so if you could help me i would be happy