[Snippet] Auto Spawn Like SA:MP

Started by MacTavish, Mar 28, 2015, 06:02 PM

Previous topic - Next topic

MacTavish

Auto Spawn Like SA:MP

Note: This system is originally made by ysc3839 i saw he isn't released it here and it has an bug,
so i fixed that bug and thought to post it here....


function onScriptLoad()
{
autospawn <- array( GetMaxPlayers(), false );
keyid <- BindKey(true,0x73,0,0);//VK_F4=0x73
}
function onKeyDown( player, bindid )
{
if(bindid == keyid && autospawn[player.ID])
{
MessagePlayer("Returning to class selection after next death",player);
autospawn[player.ID]=false;
}
}
function onPlayerRequestClass( player, classID, team, skin )
{
if(autospawn[player.ID]==true) // These was the bug
{
player.Spawn();
}
}
function onPlayerSpawn( player )
{
autospawn[player.ID]=true; // this line was in RequestClass maybe this is why when we i tried to change class it spawned me, So i put here
MessagePlayer("Press F4 to Return class selection after next death",player);
}
function onPlayerJoin( player )
{
autospawn[player.ID]=false; // i have not touched this donno why its being used
}

It is now tested, so if it has still any bug you can blame me :D

Credits: ysc3839

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

rObInX


MacTavish

#2
Quote from: rObInX on Mar 28, 2015, 06:53 PMhttp://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2656.0
This is the original post and there is no bug in the original one.

It Has an bug in RequestClass thats why i mention everything in code i am using this and i also said
QuoteThis system is originally made by ysc3839 i saw he isn't released it here

and
Quote from: Beztone on Mar 28, 2015, 05:35 PM@ysc3839:  Bro Your this system that you posted in 0.3 forum it has an bug in onPlayerRequestClass, The bug is when we try to change the class then it spawn the player i've solved the bug


Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

Quote from: Beztone on Mar 28, 2015, 07:54 PM
Quote from: rObInX on Mar 28, 2015, 06:53 PMhttp://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=2656.0
This is the original post and there is no bug in the original one.

It Has an bug in RequestClass thats why i mention everything in code i am using this and i also said
QuoteThis system is originally made by ysc3839 i saw he isn't released it here

and
Quote from: Beztone on Mar 28, 2015, 05:35 PM@ysc3839:  Bro Your this system that you posted in 0.3 forum it has an bug in onPlayerRequestClass, The bug is when we try to change the class then it spawn the player i've solved the bug


Like rObInX said, there's no bug in the original code. You're doing the exact same thing with more code.

MacTavish

then why it happened to me :\ i tried to change skin then it spawns me but after making those changes it works fine

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

rObInX

Quote from: Beztone on Mar 28, 2015, 10:46 PMthen why it happened to me :\ i tried to change skin then it spawns me but after making those changes it works fine

If you want to change the skin, disable auto-spawning.

I would suggest you to remove or lock the topic.

MacTavish


Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P