Well my player cars go away on player disconnect and when they reconnect the cars come back... But I want the cars to stay IG all the time...
code for connect.
Код:
public OnPlayerConnect(playerid)
{
new string[128];
format(string,sizeof(string), "%s has connected to the server", RPN(playerid));
foreach(Player, i)
{
if(JoinMessages[i])
{
PlayAudioStreamForPlayer(i, string);
}
}
ResetPlayerWeapons(playerid);
ResetDodWeapons(playerid);
RemoveBuildingForPlayer(playerid, 4025, 1777.8359, -1773.9063, 12.5234, 0.25);
RemoveBuildingForPlayer(playerid, 4215, 1777.5547, -1775.0391, 36.7500, 0.25);
RemoveBuildingForPlayer(playerid, 4019, 1777.8359, -1773.9063, 12.5234, 0.25);
if(IsPlayerNPC(playerid))
{
SetPlayerColor(playerid, TRANSPARENT_WHITE);
//BusText1 = CreateDynamic3DTextLabel("A-RP Administrator", COLOR_RED, 0, 0, -20, 25, playerid);
BusText1 = CreateDynamic3DTextLabel("GOD", COLOR_WHITE, 0, 0, -20, 13, playerid);
//BusText3 = CreateDynamic3DTextLabel("Server Creator", COLOR_BLUE, 0, 0, -20, 13, playerid);
//BusTest1 = Attach3DTextLabelToPlayer(Text3D:id, playerid, Float:OffsetX, Float:OffsetY, Float:OffsetZ);
//Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, BusText1 , E_STREAMER_ATTACH_OFFSET_Z, 0.25);
Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, BusText1 , E_STREAMER_ATTACH_OFFSET_Z, 0.13);
//Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, BusText3 , E_STREAMER_ATTACH_OFFSET_Z, 0.13);
return 1;
}
gHeaderTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gBackgroundTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gCurrentPageTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gNextButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
gPrevButtonTextDrawId[playerid] = PlayerText:INVALID_TEXT_DRAW;
for(new x=0; x < SELECTION_ITEMS; x++) {
gSelectionItems[playerid][x] = PlayerText:INVALID_TEXT_DRAW;
}
gItemAt[playerid] = 0;
aDuty[playerid] = 0;
mDuty[playerid] = 0;
//loginscreen
TextDrawShowForPlayer(playerid,WebTD);
TextDrawShowForPlayer(playerid,TimeTD);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[0]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[1]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[2]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[3]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[4]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[7]);
TextDrawShowForPlayer(playerid,MainMenuTxtdraw[8]);
// MAX IPS
new connecting_ip[32+1];
GetPlayerIp(playerid,connecting_ip,32);
new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
SendClientMessage(playerid, COLOR_LIGHTRED, "If you think its unfair ban, then appeal on forums.");
format(string, sizeof(string), "AdmCmd: %s has been banned by GOD, reason: Bots Attack", RPN(playerid));
SendClientMessageToAll(COLOR_LIGHTRED, string);
// Banning
PlayerInfo[playerid][pBanned] = 1;
// Banreason
new file[32];
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
dini_Set(file, "BanReason", "Bots Attack");
dini_Set(file, "BannedBy", "GOD");
AddBan(playerid);
Kick(playerid);
return 1;
}
// DONE
ClearChar(playerid);
// NAME CHECK
new playername[32], pfile[64];
format(pfile, sizeof(pfile), "users/%s.ini", RPNU(playerid));
if(!dini_Exists(pfile))
{
GetPlayerName(playerid, playername, sizeof(playername));
// Has numbers
if(strfind(playername, "0", true) != -1 || strfind(playername, "1", true) != -1 || strfind(playername, "2", true) != -1 || strfind(playername, "3", true) != -1 || strfind(playername, "4", true) != -1 || strfind(playername, "5", true) != -1
|| strfind(playername, "6", true) != -1 || strfind(playername, "7", true) != -1 || strfind(playername, "8", true) != -1 || strfind(playername, "9", true) != -1 || strfind(playername, "[", true) != -1 || strfind(playername, "]", true) != -1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "This is a RP Server, please reconnect using Firstname_Lastname format.");
SendClientMessage(playerid, COLOR_LIGHTRED, "Also, please remove the numbers and/or tags in your name.");
Kick(playerid);
}
// No Underscore
if(strfind( playername, "_", true) == -1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "This is a RP Server, please reconnect using Firstname_Lastname format.");
Kick(playerid);
}
}
// Done
PlayerInfo[playerid][pLoggedIn] = 0;
PlayerInfo[playerid][pSpawn] = 0;
PlayerInfo[playerid][pTutorial] = 1;
PlayerPaintballing[playerid] = 0;
//C4 done
Pspawned[playerid] = 0;
SetPlayerColor(playerid, TRANSPARENT_GREY);
new file[64];
format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
// Checking for rangeban
new range[4][4];
split(RPIP(playerid), range, '.');
format(string, sizeof(string), "%s.%s.*.*", range[0], range[1]);
if(CheckBan(string) == 1 && !dini_Int(file, "Whitelisted"))
{
SetPlayerName(playerid, "BannedPlayer");
SendClientMessage(playerid, COLOR_LIGHTRED, "Your range is banned from this server.");
Kick(playerid);
return 1;
}
// Checking for IP ban
if(CheckBan(RPIP(playerid)) == 1)
{
SetPlayerName(playerid, "BannedPlayer");
SendClientMessage(playerid, COLOR_LIGHTRED, "You are banned from this server.");
Kick(playerid);
return 1;
}
// Checking for character ban
if(dini_Int(file, "pBanned") == 1)
{
SetPlayerName(playerid, "BannedPlayer");
SendClientMessage(playerid, COLOR_LIGHTRED, "You are banned from this server.");
AddBan(playerid);
Kick(playerid);
return 1;
}
return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
// Bank Robbery
if(BankRobber[playerid])
{
new Rob = BankRobber[playerid]-1, string[128];
DisablePlayerCheckpoint(playerid);
BankRobbersCount --;
format(BankRobbers[Rob], MAX_PLAYER_NAME, "");
DeliverMoney[playerid] = 0;
//
foreach(Player, i)
{
if(BankRobber[i] || PlayerInfo[i][pFac] == 1)
{
if(Rob == 0) TextDrawHideForPlayer(i, Textdraw1);
else if(Rob == 1) TextDrawHideForPlayer(i, Textdraw2);
else if(Rob == 2) TextDrawHideForPlayer(i, Textdraw3);
else if(Rob == 3) TextDrawHideForPlayer(i, Textdraw4);
else if(Rob == 4) TextDrawHideForPlayer(i, Textdraw5);
}
}
format(string, sizeof(string), "** %s has disconnected and has failed the robbery. **", RPN(playerid));
SendRobberyMessage(COLOR_LIGHTRED, string);
SendCopMessage(COLOR_LIGHTRED, string);
BankRobber[playerid] = 0;
if(BankRobbersCount == 0)
{
TextDrawHideForAll(Textdraw0);
TextDrawHideForAll(Textdraw1);
TextDrawHideForAll(Textdraw2);
TextDrawHideForAll(Textdraw3);
TextDrawHideForAll(Textdraw4);
TextDrawHideForAll(Textdraw5);
// BankRobbery = 0;
RobberyStarted = 0;
format(string, sizeof(string), "** The bank robbery has ended, $%d were stolen and $%d were saved. **", TotalStolen*10000, (TotalRobbers*10000-(TotalStolen*10000)));
SendClientMessageToAll(COLOR_YELLOW, string);
TotalRobbers = 0;
new copsonline;
foreach(Player, i)
{
if(IsACop(i)) copsonline++;
}
foreach(Player, i)
{
if(IsACop(i))
{
new Saved = (TotalRobbers*10000-(TotalStolen*10000));
GiveDodMoney(i, Saved/copsonline);
format(string, sizeof(string), "** You have received your cut from the saved money. ($%d) **", Saved/copsonline);
SendClientMessage(i, COLOR_LIME, string);
}
}
}
}
RemovePlayerAttachedObject(playerid, 0);
//paintball
if(PlayerPaintballing[playerid] == 1)
{
ResetPlayerWeapons(playerid);
ResetDodWeapons(playerid);
SetPlayerPos(playerid,1310.1110,-1368.5656,13.517786);
for(new w = 0; w < 13; w++)
{
GiveDodWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
}
}
// Boxing
new string[128];
if(Boxing[playerid])
{
// Getting other boxer's ID
new playerb = -1;
foreach(Player, i)
{
if(Boxing[i] && i != playerid) playerb = i;
}
if(playerb != -1)
{
format(string, sizeof(string), "Boxing Ring: The boxing match has ended, %s has won the match.", RPN(playerb));
SendGymMessage(COLOR_WHITE, string);
// Putting them out of the ring
SetPlayerPos(playerb, 760.9759,4.7187,1000.7084);
SetPlayerFacingAngle(playerb, 268.9407);
SetPlayerPos(playerid, 760.9759,6.1794,1000.7093);
SetPlayerFacingAngle(playerid, 268.9407);
// Giving the winner extra skill point
new oldj = strval(RPJL(playerb, JOB_BOXER));
PlayerInfo[playerb][pJobSkill][JOB_BOXER] ++;
new newj = strval(RPJL(playerb, JOB_BOXER));
if(oldj < newj)
{
format(string, sizeof(string), "** Your Boxer level is now %d, you can now cause %d more damage. **", newj, (newj*2)-2);
SendClientMessage(playerb, COLOR_YELLOW, string);
}
//
SendClientMessage(playerb, COLOR_LIME, " You have won the boxing match.");
SendClientMessage(playerid, COLOR_LIGHTRED, " You have lost the boxing match.");
// Giving Bids
new winner = pBoxer[playerb];
foreach(Player, i)
{
if(BidBoxer[i] == winner)
{
new percent, profit;
percent = (BidAmount[i]/BoxerBid[winner]) * 100;
profit = (percent * BoxerBid[pBoxer[playerid]]) / 100;
GiveDodMoney(i, BidAmount[i] + profit);
format(string, sizeof(string), " You have won $%d from bidding in the match, the money you bid has been returned as well.", profit);
SendClientMessage(i, COLOR_LIME, string);
}
BidAmount[i] = 0;
BidBoxer[i] = 0;
}
for(new w = 0; w < 13; w++)
{
GiveDodWeapon(playerb, PlayerInfo[playerb][pWeapon][w], PlayerInfo[playerb][pWeaponAmmo][w]);
}
}
for(new w = 0; w < 13; w++)
{
GiveDodWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
}
// Resetting Values
BoxingMatch = 0;
Boxer[1] = -1;
pBoxer[playerb] = 0;
Boxer[2] = -1;
pBoxer[playerid] = 0;
Boxing[playerb] = 0;
Boxing[playerid] = 0;
BoxerBid[1] = 0;
BoxerBid[2] = 0;
if(BoxTime)
{
TogglePlayerControllable(playerb, 1);
KillTimer(BoxTimer);
}
}
// The rest
if(IsPlayerLoggedIn(playerid)) {SaveChar(playerid);}
switch(reason)
{
case 0: format(string, sizeof(string), "** %s has left the server. (Timeout)", RPN(playerid));
case 1: format(string, sizeof(string), "** %s has left the server. (Leaving)", RPN(playerid));
case 2: format(string, sizeof(string), "** %s has left the server. (Kicked/Banned)", RPN(playerid));
}
SendNearbyMessage(playerid, 10, string, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW);
foreach(Player, i)
{
if(Specid[i] == playerid)
{
Spec[i] = 0;
Specid[i] = -1;
TogglePlayerSpectating(i, 0);
SetPlayerVirtualWorld(i, PlayerInfo[playerid][pVW]);
SetPlayerInterior(i, PlayerInfo[playerid][pInt]);
SetPlayerPos(i, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
SendClientMessage(i, COLOR_WHITE, " You have stopped spectating players.");
}
}
// Clearing AD
for(new i=0; i<MAX_ADS; i++)
{
if(strfind(AD[i], RPN(playerid)) != -1)
{
format(AD[i], 128, "");
}
}
// End of Clearing AD
ClearChar(playerid);
if(Planted[playerid] == 1)
{
DestroyObject(C4[playerid]);
Bomb[playerid] = 0;
Planted[playerid] = 0;
}
return 1;
}