#1

I tried to make this command, but the problem is, It respawns the player not in the same position!

Код:
CMD:sync(playerid, params[])
{
   new Float:health, Float:armour;
   new Float:x, Float:y, Float:z;
   new weaponid;
   GetPlayerHealth(playerid, health);
   GetPlayerArmour(playerid, armour);
   SetPlayerArmour(playerid, armour);
   SetPlayerHealth(playerid, health);
   new playerskin = GetPlayerSkin(playerid);
   SetPlayerSkin(playerid, playerskin);
   weaponid = GetPlayerAmmo(playerid);
   new weapon = GetPlayerWeapon(playerid);
   SetSpawnInfo(playerid,0,playerskin,x,y,z,weaponid, weapon,weaponid,weapon,weaponid,weapon,weaponid);
   GetPlayerPos(playerid, x,y,z) && SetPlayerPos(playerid,x,y,z);
   return 1;
}
Reply
#2

You need to get players position before setting his spawn info, so just put GetPlayerPos before SetSpawnInfo and it should work fine
Reply
#3

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
You need to get players position before setting his spawn info, so just put GetPlayerPos before SetSpawnInfo and it should work fine
works fine, but I don't know why it doesn't reset the player's stamina
Reply
#4

What in the heck are you doing, and who is encouraging you to do this?

You aren't doing anything with the spawn, you're just setting it. There is no SpawnPlayer reference, and most of the code here isn't needed as I suspect you are trying to get rid of desync, which isn't going to be fixed by this in many circumstances.


Like, sorry man, but what the heck...

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
works fine, but I don't know why it doesn't reset the player's stamina
And this...

Do you actually mean stamina? or something else?
Reply
#5

I've heard that syncing him properly I need to re-spawn the player (in the same position, and getting his hp, armour etc so it stays the same) and it should reset his stamina of course, that's the only way to reset it by respawning him
Reply
#6

You're not re-spawning him though in any of this code, so I don't get what you're trying to achieve...
Reply
#7

I tried doing SpawnPlayer but that just respawns him somewhere else, i need him in the same pos
Reply
#8

It's because of your order in your code...

PHP код:
   SetSpawnInfo(playerid,0,playerskin,x,y,z,weaponidweapon,weaponid,weapon,weaponid,weapon,weaponid);
   
GetPlayerPos(playeridx,y,z) && SetPlayerPos(playerid,x,y,z); 
You set his spawninfo before you got his position as was stated above.

PHP код:
CMD:sync(playeridparams[])
{
   new 
Float:healthFloat:armourFloat:xFloat:yFloat:zweaponidweaponplayerskin;
   
GetPlayerHealth(playeridhealth);
   
GetPlayerArmour(playeridarmour);
   
playerskin  GetPlayerSkin(playerid);
   
weaponid GetPlayerAmmo(playerid);
   
weapon GetPlayerWeapon(playerid);
   
GetPlayerPos(playeridx,y,z)
   
SetSpawnInfo(playerid,0,playerskin,x,y,z,weaponidweapon,weaponid,weapon,weaponid,weapon,weaponid);
   
SpawnPlayer(playerid);
   
SetPlayerArmour(playeridarmour);
   
SetPlayerHealth(playeridhealth);
   
//Won't be needed.
   //SetPlayerSkin(playerid, playerskin);
   //SetPlayerPos(playerid,x,y,z);
   
return 1;

I would also look at your use of the weaponid/weapon in the spawn info, that's something different, and shouldn't need to be set multiple times. You could use 0,0,0,0 for the last parameters instead of repeating variables.
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
It's because of your order in your code...

PHP код:
   SetSpawnInfo(playerid,0,playerskin,x,y,z,weaponidweapon,weaponid,weapon,weaponid,weapon,weaponid);
   
GetPlayerPos(playeridx,y,z) && SetPlayerPos(playerid,x,y,z); 
You set his spawninfo before you got his position as was stated above.

PHP код:
CMD:sync(playeridparams[])
{
   new 
Float:healthFloat:armourFloat:xFloat:yFloat:zweaponidweaponplayerskin;
   
GetPlayerHealth(playeridhealth);
   
GetPlayerArmour(playeridarmour);
   
playerskin  GetPlayerSkin(playerid);
   
weaponid GetPlayerAmmo(playerid);
   
weapon GetPlayerWeapon(playerid);
   
GetPlayerPos(playeridx,y,z)
   
SetSpawnInfo(playerid,0,playerskin,x,y,z,weaponidweapon,weaponid,weapon,weaponid,weapon,weaponid);
   
SpawnPlayer(playerid);
   
SetPlayerArmour(playeridarmour);
   
SetPlayerHealth(playeridhealth);
   
//Won't be needed.
   //SetPlayerSkin(playerid, playerskin);
   //SetPlayerPos(playerid,x,y,z);
   
return 1;

I would also look at your use of the weaponid/weapon in the spawn info, that's something different, and shouldn't need to be set multiple times. You could use 0,0,0,0 for the last parameters instead of repeating variables.
It respawns me to another place, (since I have randomspawns), so it just calls them
Reply
#10

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
It respawns me to another place, (since I have randomspawns), so it just calls them
Then you need to make a check before using those random spawns as to whether they went through the right way to getting to spawn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)