Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Nihongo^ on Aug 19, 2023, 04:48 PM

Title: Spec not work on player.world
Post by: Nihongo^ on Aug 19, 2023, 04:48 PM
i have problem in /spec
when player died the spec system stopped working its due to player.world = 2
i used plr.Word =2 for anti spawn killing

so when player spawn spec stop working

how do i make it work again ? as the player.wolrd = 2 take 3 seconds to send the world 1
so i want to it work again without waiting for the plr to set world 1
function AntiSpawn(player)
{
player.World = 2;

NewTimer( "AntiSpawnOff", 5000, 1, player.ID );
Announce( "~o~ SPAWN PROTECTION IS ON !" , player);
player.CanAttack = false;
}

function AntiSpawnOff( player )
{
local plr = FindPlayer(player);
if(plr) {
plr.World = 1;
Announce( "~G~ SPAWN PROTECTION IS OFF !" ,plr );
plr.CanAttack = true;
}
}
function onPlayerSpawn( player )
{
AntiSpawn(player)
}
Title: Re: Spec not work on player.world
Post by: Mohamed Boubekri on Aug 19, 2023, 05:49 PM
-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.
Title: Re: Spec not work on player.world
Post by: Nihongo^ on Aug 19, 2023, 05:51 PM
Quote from: Mohamed Boubekri on Aug 19, 2023, 05:49 PM-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.

One of my friend help me with this but it gives error by saying "world doesn't exists"

if(target.World == 1) return true;

function onPlayerSpectate( player, target )
{

if(player.IsSpawned == false || player.World == 1)
{
if(target.World == 1) return true;

else{

for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p.IsSpawned == true && p.World == 1)
{
target = p.ID;
}
}

}
}

}
Title: Re: Spec not work on player.world
Post by: Mohamed Boubekri on Aug 19, 2023, 06:00 PM
Quote from: Nihongo^ on Aug 19, 2023, 05:51 PMOne of my friend help me with this but it gives error by saying "world doesn't exists"
This error appears, if the defined player doesen't exist.
Add this:
if (!target) return;before that line:
if(target.World == 1) return true;
Title: Re: Spec not work on player.world
Post by: Nihongo^ on Aug 19, 2023, 06:08 PM
wait,
if (!target) return;
return it and the function won't work -_- i really want a spec system to work when plr world is 2 or wait till plr wait get 1
Title: Re: Spec not work on player.world
Post by: Mohamed Boubekri on Aug 19, 2023, 06:26 PM
Create it by yourself, i already give you an idea.

Quote from: Mohamed Boubekri on Aug 19, 2023, 05:49 PM-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.
Title: Re: Spec not work on player.world
Post by: Nihongo^ on Aug 20, 2023, 12:54 PM
Quote from: Mohamed Boubekri on Aug 19, 2023, 06:26 PMCreate it by yourself, i already give you an idea.

Quote from: Mohamed Boubekri on Aug 19, 2023, 05:49 PM-Try to detect if player is on spectating mode, i mean like a status, then add that line:
Example: if ( status[player.ID].Spec == true ) return player.SpectateTarget = false;
And again try to define the target: player.SpectateTarget = target;

-Also you can hold the target in array, then try to refresh the spectate system after player world changed.

I'll surely use my hands with no problem, while I already have function onPlayerSpectate( player, target )
but it said the world doesn't exist, so just a simple question is that why it saying that world not exist
when the target is already in the spectate
Title: Re: Spec not work on player.world
Post by: vitovc on Aug 22, 2023, 07:18 AM
Make sure Spectator himself (player who spec) is having same world as spectator's target
Title: Re: Spec not work on player.world
Post by: Nihongo^ on Aug 22, 2023, 07:51 AM
Quote from: vitovc on Aug 22, 2023, 07:18 AMMake sure Spectator himself (player who spec) is having same world as spectator's target
Is there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
Title: Re: Spec not work on player.world
Post by: vitovc on Aug 22, 2023, 07:09 PM
Quote from: Nihongo^ on Aug 22, 2023, 07:51 AMIs there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
Events are for not to wait. You can write "timer" yourself to delay spectate act when conditions will be right.
Title: Re: Spec not work on player.world
Post by: Nihongo^ on Aug 23, 2023, 08:02 AM
Quote from: vitovc on Aug 22, 2023, 07:09 PM
Quote from: Nihongo^ on Aug 22, 2023, 07:51 AMIs there any way onPlayerSpectate can wait until the player ( whom i am spectating ) world set to 1 ?
Events are for not to wait. You can write "timer" yourself to delay spectate act when conditions will be right.
I have one confusion
we can put the player in spec mode with player.SpectateTarget = plr;
What about the "plr" ? ( which goes die )
When he spawns his world change player.world = 2, so how do i tell the script i was spec him

sorry for the such noob question 
Title: Re: Spec not work on player.world
Post by: Gulk on Aug 28, 2023, 05:39 PM
You can avoid this entirely,
Preferably use REAL spawn protection with immunities, then disable immunities after the time, or when the player shoots (excluding the fist(or brassknuckles) from the shoot event, and set it(fist) as the wep they spawn equipped - this will prevent accident protection de-activation)

that's how I've set it in XE