Sync Problem
#1

Well I'm still learning Codes and i'm trying to make this sync script that i copied from a GM to work on FS or even in GM
but it only works once when i type /sync.

Please Help me Thanks!!!


Heres the whole pwn code.
Код:
#include <a_samp>
#include <zcmd>
#include <foreach>

#define FILTERSCRIPT
#define MAX_TEAMS 		1
#undef MAX_PLAYERS
#define MAX_PLAYERS     30


enum PlayerVariables {
	Name[MAX_PLAYER_NAME],
	NameWithoutTag[MAX_PLAYER_NAME],
	bool:Logged,
	bool:IgnoreSpawn,
	bool:InDM,
	bool:Syncing,
	bool:Playing,
	bool:WasInCP,
	bool:IsKicked,
	bool:Spectating,
	bool:BeingSpeced,
	bool:CalledByPlayer,
	bool:WasInBase,
	bool:TextDrawOnScreen,
	bool:Spawned,
	bool:IsAFK,
	IsSpectatingID,
	Level,
	Weather,
	Time,
	Team,
	DLlast,
	FPS,
	Float:pHealth,
	Float:pArmour,
	DMReadd,
	RoundKills,
	RoundDeaths,
	Float:RoundDamage,
	TotalKills,
	TotalDeaths,
	Float:TotalDamage,
	WeaponPicked,
	OutOfArena,
	PacketKick,
	PingKick,
	FPSKick,
	DeathIcon
}
new Player[MAX_PLAYERS][PlayerVariables];
new Skin[MAX_TEAMS];

public OnFilterScriptInit()
{
	return 1;
}
public OnFilterScriptExit()
{
	return 1;
}
/*
CMD:s(playerid, params[]) return cmd_sync(playerid, params);
CMD:sync(playerid, params[])
{
    new Float:asdA, Float:asdX, Float:asdY, Float:asdZ;
    GetPlayerPos(playerid,asdX,asdY,asdZ);
    GetPlayerFacingAngle(playerid,asdA);
    SpawnPlayer(playerid);
    SetPlayerPos(playerid,asdX,asdY,asdZ + 0.5);
    SetPlayerFacingAngle(playerid,asdA);
    PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
    TogglePlayerControllable(playerid,1);
    SendClientMessage(playerid,0xD8F6F6FF,"You are now synched.");
    return 1;
}
*/
CMD:sync(playerid, params[])
{
	SyncPlayer(playerid);
	return 1;
}

SyncPlayer(playerid)
{
	if(Player[playerid][Syncing] == true) return 1;
	if(IsPlayerInAnyVehicle(playerid)) return 1;

	Player[playerid][Syncing] = true;
	SetTimerEx("SyncInProgress", 1000, false, "i", playerid);

	new bool:IsPlayerSpecing[MAX_PLAYERS] = false;
	foreach(new i : Player) {
	    if(Player[i][Spectating] == true && Player[i][IsSpectatingID] == playerid) {
	        IsPlayerSpecing[i] = true;
		}
	}

	new Float:HP[2], Float:Pos[4], Int, VirtualWorld;
	GetPlayerHealth(playerid, HP[0]);
	GetPlayerArmour(playerid, HP[1]);

	GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
	GetPlayerFacingAngle(playerid, Pos[3]);

	Int = GetPlayerInterior(playerid);
	VirtualWorld = GetPlayerVirtualWorld(playerid);

	new Weapons[13][2];
	for(new i = 0; i < 13; i++) {
	    GetPlayerWeaponData(playerid, i, Weapons[i][0], Weapons[i][1]);
	}

	ClearAnimations(playerid);
	Player[playerid][IgnoreSpawn] = true;

	SetSpawnInfo(playerid, GetPlayerTeam(playerid), Skin[Player[playerid][Team]], Pos[0], Pos[1], Pos[2]-0.4, Pos[3], 0, 0, 0, 0, 0, 0);
	SpawnPlayerEx(playerid);

	SetPlayerHealth(playerid, HP[0]);
	SetPlayerArmour(playerid, HP[1]);

	SetPlayerInterior(playerid, Int);
	SetPlayerVirtualWorld(playerid, VirtualWorld);

	for(new i = 0; i < 13; i++) {
	    GivePlayerWeapon(playerid, Weapons[i][0], Weapons[i][1]);
	}

	foreach(new i : Player) {
	    if(IsPlayerSpecing[i] == true) {
	        SetTimerEx("ReSpectatePlayer", GetPlayerPing(playerid) + GetPlayerPing(i), false, "ii", i, playerid);
		}
	}

	return 1;
}

SpawnPlayerEx(playerid)
{
	if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
	SetPlayerPos(playerid, 0, 0, 0);
	SpawnPlayer(playerid);
}
Reply
#2

I don't think you set the following variable to false:
pawn Код:
if(Player[playerid][Syncing] == true) return 1;
That's why you are only able to sync once.

Try doing this:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(Player[playerid][Syncing])
        Player[playerid][Syncing] = false;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)