Question

Постоянный

Всем привет, когда захожу на сервер, выбираю пункт спавна "Где вышел", телепортирует на координаты 0.0.0.

Мод: AttractRP

Буду рад помощи :$

Share this post


Link to post

10 answers to this question

  • 0
DEST
Maintainer

@Aurum значит не сохраняются координаты, проверь есть ли они в базе

Share this post


Link to post
  • 0
Постоянный
24 минуты назад, DEST сказал:

@Aurum значит не сохраняются координаты, проверь есть ли они в базе

В базе, как таковые значения имеются.

Но, как Вы и сказали, координаты не сохраняются. ( В таблице значений нет ).

Я с мускулом на самом деле не шарю.

Если можете помочь - помогите пожалуйста, что надо - кину.

Share this post


Link to post
  • 0
DEST
Maintainer

@Aurum OnPlayerDisconnect скинь и названия полей в которых должны быть значения

Share this post


Link to post
  • 0
Постоянный
Спойлер

public OnPlayerDisconnect(playerid, reason)
{
	new string1[128];
	switch(reason)
	{
		case 0: strmid(string1, "ошибка", 0, strlen("ошибка"));
		case 1: strmid(string1, "вышел", 0, strlen("Вышел"));
		case 2: strmid(string1, "кик/бан", 0, strlen("кик/бан"));
		default: strmid(string1, "неизвестно", 0, strlen("неизвестно"));
	}
	format(string1, 128, "[A] %s[%d] отключился | IP: %s | Причина: %s.",PI[playerid][pName],playerid,PI[playerid][pIP],string1);
	SendBoxMessage(string1);
    slotUsed{playerid} = false;
    PI[playerid][pOnline] = 0;
    KillTimer(player_timer[playerid]);
    if(PI[playerid][cModel] > 0) Delete3DTextLabel(VehicleLabel[PI[playerid][PlayerCarID]]);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 0)) RemovePlayerAttachedObject(playerid, 0);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, 1);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 2)) RemovePlayerAttachedObject(playerid, 2);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 3)) RemovePlayerAttachedObject(playerid, 3);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 4)) RemovePlayerAttachedObject(playerid, 4);
	if(IsPlayerAttachedObjectSlotUsed(playerid, 5)) RemovePlayerAttachedObject(playerid, 5);
	new Query[128];
	format(Query, sizeof(Query), "UPDATE "T_ADMIN" SET timemin='%d' WHERE name='%s' LIMIT 1", AdminInfo[playerid][admTimeMin], GetName(playerid));
	mysql_tquery(dbHandle, Query, "", "");
	if(GetPVarInt(playerid,"DrawFill") > 0) DeletePVar(playerid,"DrawFill");
	if(PI[playerid][PlayerCarID] != INVALID_VEHICLE_ID)
	{
		PI[playerid][cFuel] = Fuel[PI[playerid][PlayerCarID]];
		DestroyVehicle(PI[playerid][PlayerCarID]);
		PI[playerid][PlayerCarID] = INVALID_VEHICLE_ID;
	}
	if(pCuff[playerid][pCuffee] != INVALID_PLAYER_ID && reason == 1)
	{
	    new id = pCuff[playerid][pCuffee];
	    if(id == playerid)
		{
		    new cuffer = pCuff[playerid][pCuffer];
		    new string[128];
			format(string, sizeof(string), "%s вышел при аресте (+30 минут КПЗ)", GetName(playerid));
			SendClientMessageToAll(COLOR_RED, string);
			PI[playerid][pJail] = 4;
			PI[playerid][pJailTime] = 1800;
			PI[playerid][pWanted] = 0;
			pCuff[cuffer][pCuffer] = INVALID_PLAYER_ID;
			pCuff[cuffer][pCuffee] = INVALID_PLAYER_ID;
			pCuff[playerid][pCuffee] = INVALID_PLAYER_ID;
			pCuff[playerid][pCuffer] = INVALID_PLAYER_ID;
		}
		else if(!IsPlayerConnected(id))
		{
		    SetPlayerSpecialAction(id, SPECIAL_ACTION_NONE);
			RemovePlayerAttachedObject(id, 0);
			pCuff[id][pCuffer] = INVALID_PLAYER_ID;
			pCuff[id][pCuffee] = INVALID_PLAYER_ID;
			pCuff[playerid][pCuffee] = INVALID_PLAYER_ID;
			pCuff[playerid][pCuffer] = INVALID_PLAYER_ID;
			SendClientMessage(playerid, COLOR_LIME, "Офицер, надевший на Вас наручники, вышел из игры. Наручники сняты.");
		}
	}
 	if(GetPVarInt(playerid, "arendkey") != -1)
	{
		new v = GetPVarInt(playerid, "arendkey");
		if(ArendInfo[v][aPlayerID] == playerid)
		{
			ArendInfo[v][aPlayerID] = INVALID_PLAYER_ID;
            SetVehicleToRespawn(ArendInfo[v][aID]);
            IsLocked[ArendInfo[v][aID]] = false;
			CarDoorsEx(ArendInfo[v][aID], 0);
		}
    }
//_______________________| Выход с сервера во время работы |____________________
	if(GetPVarInt(playerid, "TruckerJob"))//дальнобойщики
	{
	    DestroyVehicleEx(TruckerCar[playerid]);
	    TruckerCar[playerid] = 0;
		DeletePVar(playerid, "TruckerJobTime");
		DeletePVar(playerid, "TruckerJob");
		DeletePVar(playerid, "TruckerJobRazgruzka");
	}
	if(GetPVarInt(playerid, "InJobVodolaz") == 1)//водолазы
	{
	    KillTimer(Vozduh[playerid]);
	    RemovePlayerAttachedObject(playerid,1);
	    RemovePlayerAttachedObject(playerid,2);
	    RemovePlayerAttachedObject(playerid,8);
        RemovePlayerAttachedObject(playerid,5);
        GiveMoney(playerid,GetPVarInt(playerid,"JobVodolazYashiki")*JOB_CASH_VODOLAZ);// Выдаём деньги
        DeletePVar(playerid,"JobVodolazYashiki");// Удаляем PVar с колличеством вещей
        DeletePVar(playerid,"InJobVodolaz");
        DeletePVar(playerid, "VodolazMeshok1");
        DeletePVar(playerid, "VodolazMeshok2");
        DeletePVar(playerid, "VodolazGoToSklad");
        SetHealth(playerid,100);
	}
	if(GetPVarInt(playerid,"objectcop"))
	{
		DestroyObject(GetPVarInt(playerid,"objectcop"));
		DestroyDynamicArea(Ships[playerid]);
	}
	PlayerDied[playerid] = false;
	drawcapt[playerid] = false;
	SetPlayerSkills(playerid);
 	if(PlayerUseMask[playerid])
	{
        PlayerUseMask[playerid] = false;
		KillTimer(MaskTimer[playerid]);
	}
	if(UseGPS[playerid])
	{
    	DisablePlayerRaceCheckpoint(playerid);
    	UseGPS[playerid] = false;
	}
	if(GetPVarInt(playerid, "PriceBus") > 0)
	{
		PI[playerid][pPayCheck] += GetPVarInt(playerid, "BusMoney");
		if(IsValidDynamic3DTextLabel(BusText3D[playerid])) DestroyDynamic3DTextLabel(BusText3D[playerid]);
		SetVehicleToRespawn(PI[playerid][BusCarID]);
	}
	if(GetPVarInt(playerid, "PriceTaxi") > 0)
	{
		PI[playerid][pPayCheck] += GetPVarInt(playerid, "TaxiMoney");
		if(IsValidDynamic3DTextLabel(TaxiText3D[playerid])) DestroyDynamic3DTextLabel(TaxiText3D[playerid]);
		SetVehicleToRespawn(PI[playerid][TaxiCarID]);
	}
	if(PI[playerid][MechanicCarID] != INVALID_VEHICLE_ID) SetVehicleToRespawn(PI[playerid][MechanicCarID]);
	if(UseWork[playerid] == 2)
	{
	    DeletePVar(playerid, "OldLessSkin");
		UseWork[playerid] = 0;
		DeletePVar(playerid, "LessProgress");
		DeletePVar(playerid, "Derevo");
		DeletePVar(playerid, "LessStatus");
		if(IsPlayerAttachedObjectSlotUsed(playerid, 3)) RemovePlayerAttachedObject(playerid, 3);
		if(IsPlayerAttachedObjectSlotUsed(playerid, 4)) RemovePlayerAttachedObject(playerid, 4);
	}
	
	foreach(new i: Player)
	{
        if(GetPlayerState(i) == PLAYER_STATE_SPECTATING && PI[i][Spectating][0] == playerid)
        {
            GameTextForPlayer(i, "PLAYER DISCONNECTED", 3000, 3);
            cmd_specoff(i, "");
	    }
	}
//_________________| Скрытие текстдравов после выхода игрока |__________________
	for(new i = 0; i < 6; i++) TextDrawHideForPlayer(playerid, Button[i]);
	
    for(new i = 0; i < 10; i++)
	{
		PlayerTextDrawDestroy(playerid, SecurityCode[playerid][i]);
		SecurityCode[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
	}
	for(new i = 0; i < 6; i++)
	{
		PlayerTextDrawDestroy(playerid, StatusWork[playerid][i]);
		StatusWork[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
	}
	for(new i = 0; i < 4; i++)
	{
		PlayerTextDrawDestroy(playerid, GreenZoneText[playerid][i]);
		GreenZoneText[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
	}
	for(new i = 0; i < 7; i++)
	{
	    PlayerTextDrawDestroy(playerid, CaptureTD[playerid][i]);
		CaptureTD[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
	}
	CancelSelectTextDraw(playerid);
//________________________| Сохранение оружия у игрока при выходе |_____________
	new gun_string[56], ammo_string[56], string[256];
	format(gun_string, 56, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	PI[playerid][pGun][0], PI[playerid][pGun][1], PI[playerid][pGun][2], PI[playerid][pGun][3],
	PI[playerid][pGun][4], PI[playerid][pGun][5], PI[playerid][pGun][6], PI[playerid][pGun][7],
	PI[playerid][pGun][8], PI[playerid][pGun][9], PI[playerid][pGun][10], PI[playerid][pGun][11],
	PI[playerid][pGun][12]);
	
	format(ammo_string, 56, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	PI[playerid][pAmmo][0], PI[playerid][pAmmo][1], PI[playerid][pAmmo][2], PI[playerid][pAmmo][3],
	PI[playerid][pAmmo][4], PI[playerid][pAmmo][5], PI[playerid][pAmmo][6], PI[playerid][pAmmo][7],
	PI[playerid][pAmmo][8], PI[playerid][pAmmo][9], PI[playerid][pAmmo][10], PI[playerid][pAmmo][11],
	PI[playerid][pAmmo][12]);
	
	format(string, sizeof(string), "UPDATE "T_ACCOUNTS" SET `guns` = '%s',`ammos` = '%s' WHERE `id` = '%i'", gun_string, ammo_string, PI[playerid][pID]);
	mysql_tquery(dbHandle, string, "", "");
//______________________________________________________________________________
	SaveAccount(playerid);
	SetPlayerDataToDefault(playerid);
	return 1;
}

 

Названия полей:

PosX , PosY , PosZ

Edited by Aurum

Share this post


Link to post
  • 0
Постоянный
Спойлер

 


enum pInfo {
...
	Float:PosX,
    Float:PosY,
    Float:PosZ,
    pInt,
    pWorld,
};

forward OnPlayerLogin(playerid, tmp[]);
public OnPlayerLogin(playerid, tmp[])
{
...
	new posx[3];
    new posy[3];
    new posz[3];
    new pint[3];
    new pworld[3];
...
	cache_get_field_content(0,"pInt",pint), PI[playerid][pInt] = strval(pint);
    cache_get_field_content(0,"pWorld",pworld), PI[playerid][pWorld] = strval(pworld);
    cache_get_field_content(0,"PosX",posx), PI[playerid][PosX] = floatstr(posx);
    cache_get_field_content(0,"PosY",posy), PI[playerid][PosY] = floatstr(posy);
    cache_get_field_content(0,"PosZ",posz), PI[playerid][PosZ] = floatstr(posz);
	return 1;
};

stock SaveAccount(playerid)
{
...
	format(src,sizeof(src),"pInt='%d',",PI[playerid][pInt]);
	strcat(query,src,sizeof(query));
	format(src,sizeof(src),"pWorld='%d',",PI[playerid][pWorld]);
	strcat(query,src,sizeof(query));
	format(src,sizeof(src),"PosX='%f',",PI[playerid][PosX]);
	strcat(query,src,sizeof(query));
	format(src,sizeof(src),"PosY='%f',",PI[playerid][PosY]);
	strcat(query,src,sizeof(query));
	format(src,sizeof(src),"PosZ='%f',",PI[playerid][PosZ]);
	strcat(query,src,sizeof(query));
	return 1;
}

stock SavePos(playerid)
{
    new Float:X;
    new Float:Y;
    new Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    PI[playerid][PosX] = X;
    PI[playerid][PosY] = Y;
    PI[playerid][PosZ] = Z;
    PI[playerid][pInt] = GetPlayerInterior(playerid);
    PI[playerid][pWorld] = GetPlayerVirtualWorld(playerid);
    SaveAcc();
    return true;
}

stock SetPos(playerid)
{
    SetPlayerInterior(playerid, PI[playerid][pInt]);
    SetPlayerVirtualWorld(playerid, PI[playerid][pWorld]);
    SetPlayerPos(playerid, PI[playerid][PosX],PI[playerid][PosY],PI[playerid][PosZ]);
    return true;
}

 

Кажется тута все)

Edited by Aurum

Share this post


Link to post
  • 0
Постоянный
3 минуты назад, DEST сказал:

@Aurum где SavePos вызывается? 

А вот и оно. Нигде!

Я так подозреваю, вызывать сток при отключении игрока?

Share this post


Link to post
  • 0
Постоянный
1 час назад, DEST сказал:

@Aurum где SavePos вызывается? 

И все-таки не получается. 

Координаты в базу не записываются.

Share this post


Link to post
  • 0
DEST
Maintainer

@Aurum и не будет получаться, курим wiki.sa-mp.com: 

Цитата

Некоторые функции могут работать некорректно при использовании в этом обратном вызове, потому что когда функция вызывается игрок уже отключен. Это означает, что вы не можете получить однозначную информацию от таких функций, как GetPlayerIp и GetPlayerPos.

http://wiki.sa-mp.com/wiki/OnPlayerDisconnect_RU

Соответственно вызывать нужно в секундном таймере. И если SaveAcc() выполняет полное сохранение аккаунта, то его лучше будет убрать из стока SavePos. 

Share this post


Link to post
This topic is now closed to further replies.
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DonK/Key
      Всем привет, помогите кто разбирается, так как я можно сказать начинающий сделать свой КРМП, буду благодарен. Напишите либо тут либо @evreI_sigma (Мой Telegram)