SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 29/05/2019, 03:58 PM   #1
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 87
Default RESAPWN (GTA 5 Online Style)


RESPAWN

Respawn just like in gta 5 online, when you die you will be spectating the player that killed you, the screen will become grey with black box and progress bar on buttom right corner you can wait for the bar to fill it self or press lmb to fill it faster once its filled you will respawn.



Video: "https://www.y-0-u-t-u-b-e.com/watch?v=wO7HfUwHH1M"

Requirements: progress2.inc

Github: Click here

Download: Click here

Pics:






Bugs:

If you find any bugs please report.


Credits:

SA-MP team - a_samp
Lokii - respawn
Southclaw - progress2
__________________

Last edited by Lokii; 15/10/2019 at 09:21 AM.
Lokii is offline   Reply With Quote
Old 29/05/2019, 06:35 PM   #2
SonnyGamer
Huge Clucker
 
SonnyGamer's Avatar
 
Join Date: Jun 2017
Posts: 319
Reputation: 85
Default Re: RESAPWN (GTA 5 Online Style)

Useful script
Thanks for sharing
SonnyGamer is offline   Reply With Quote
Old 29/05/2019, 11:22 PM   #3
MaxStyle
Little Clucker
 
Join Date: Nov 2017
Posts: 2
Reputation: 0
Default Re: RESAPWN (GTA 5 Online Style)

Awesome! Thanks.
MaxStyle is offline   Reply With Quote
Old 30/05/2019, 01:17 PM   #4
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 87
Default Re: RESAPWN (GTA 5 Online Style)

Quote:
Originally Posted by SonnyGamer View Post
Useful script
Thanks for sharing
Quote:
Originally Posted by MaxStyle View Post
Awesome! Thanks.
Thx
__________________
Lokii is offline   Reply With Quote
Old 30/05/2019, 08:41 PM   #5
Variable™
Gangsta
 
Join Date: Jul 2015
Posts: 798
Reputation: 175
Default Re: RESAPWN (GTA 5 Online Style)

Good effort.

Regarding the code, here are some tips:

1. This loop is bad, the variable "j" will not be limited to the loop but the whole callback which isn't good either, keeping declarations where they're needed is better.

This is wrong:
pawn Code:
new j;
    j = GetPlayerPoolSize();
    for(new i = 0; i <= j; i++)
    {
        //Your code here...
    }

This is correct:
pawn Code:
for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
        //Your code here...
    }

2. It's not recommended to return 1 on the top of a callback, because it stops the code below it from functioning. You could check if the player isn't an NPC instead of returning 1.

You also don't need to check if the player is an NPC at all, this filterscript doesn't include anything for NPCs so it should work fine for most people, if someone has problems with NPCs they can add the NPC check themselves.

This stops whole code from working, and including it in some callbacks like OnPlayerKeyStateChange can cause problems as rest of code wouldn't work, so better avoid it:
pawn Code:
if(IsPlayerNPC(playerid)) return 1;

Simply just don't run that part of code if the player is an NPC, i.e. don't create the progress bar:
pawn Code:
if(!IsPlayerNPC(playerid)) {
        //Write your code here...
    }

3. Personally I don't like how this timer is called every 100ms, every time a player dies, so if 100 players die, you have a timer running 10 times per second for each.
pawn Code:
VD_TIMER[playerid] = SetTimerEx("CLICK_CHECK", 100, true, "i", playerid);

Since the code depends on VD_VALUE, you could increase it under OnPlayerUpdate then simply call the function "CLICK_CHECK" (no need to forward it anymore) to hide the TDs, progressbar and respawn player. If you're worried about frequently updating progress bar value under OnPlayerUpdate, only do it every +10%. Like if VD_VALUE is 10%, update it, then at 20% and so on.

4. Don't do this:
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(VD_TIMER[playerid] < 1.0) return 1;
    if(newkeys & KEY_FIRE)
    {
        VD_VALUE[playerid] += 10.0;
        if(VD_VALUE[playerid] >= 100.0)
        {
            TogglePlayerSpectating(playerid, 0);
            KillTimer(VD_TIMER[playerid]);
            VD_TIMER[playerid] = 0;
            TextDrawHideForPlayer(playerid, VD_BOX);
            TextDrawHideForPlayer(playerid, VD_BOX2);
            TextDrawHideForPlayer(playerid, VD_TEXT);
            HidePlayerProgressBar(playerid, VD_BAR[playerid]);
            SpawnPlayer(playerid);
            return 1;
        }
        SetPlayerProgressBarValue(playerid, VD_BAR[playerid], VD_VALUE[playerid]);
        return 1;
    }
    return 1;
}

This is pretty bad:
pawn Code:
if(VD_TIMER[playerid] < 1.0) return 1;

Firstly VD_TIMER is an integer not a decimal so you don't need this *.0. Besides, don't return 1, just execute the code if VD_TIMER is above 1 by doing it like this:
pawn Code:
if(VD_TIMER[playerid]) {
        //Your code here...
    }
__________________
Discord | Website
Variable™ is offline   Reply With Quote
Old 31/05/2019, 02:15 AM   #6
zKaioDzn
Big Clucker
 
Join Date: May 2019
Location: .
Posts: 77
Reputation: 0
Default Re: RESAPWN (GTA 5 Online Style)

Belo fs, mas ainda modificarei algumas coisas
zKaioDzn is offline   Reply With Quote
Old 01/06/2019, 05:09 PM   #7
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 375
Reputation: 87
Default Re: RESAPWN (GTA 5 Online Style)

Quote:
Originally Posted by Variable™ View Post
Good effort.

Regarding the code, here are some tips:

1. This loop is bad, the variable "j" will not be limited to the loop but the whole callback which isn't good either, keeping declarations where they're needed is better.

This is wrong:
pawn Code:
new j;
    j = GetPlayerPoolSize();
    for(new i = 0; i <= j; i++)
    {
        //Your code here...
    }

This is correct:
pawn Code:
for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
        //Your code here...
    }

2. It's not recommended to return 1 on the top of a callback, because it stops the code below it from functioning. You could check if the player isn't an NPC instead of returning 1.

You also don't need to check if the player is an NPC at all, this filterscript doesn't include anything for NPCs so it should work fine for most people, if someone has problems with NPCs they can add the NPC check themselves.

This stops whole code from working, and including it in some callbacks like OnPlayerKeyStateChange can cause problems as rest of code wouldn't work, so better avoid it:
pawn Code:
if(IsPlayerNPC(playerid)) return 1;

Simply just don't run that part of code if the player is an NPC, i.e. don't create the progress bar:
pawn Code:
if(!IsPlayerNPC(playerid)) {
        //Write your code here...
    }

3. Personally I don't like how this timer is called every 100ms, every time a player dies, so if 100 players die, you have a timer running 10 times per second for each.
pawn Code:
VD_TIMER[playerid] = SetTimerEx("CLICK_CHECK", 100, true, "i", playerid);

Since the code depends on VD_VALUE, you could increase it under OnPlayerUpdate then simply call the function "CLICK_CHECK" (no need to forward it anymore) to hide the TDs, progressbar and respawn player. If you're worried about frequently updating progress bar value under OnPlayerUpdate, only do it every +10%. Like if VD_VALUE is 10%, update it, then at 20% and so on.

4. Don't do this:
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(VD_TIMER[playerid] < 1.0) return 1;
    if(newkeys & KEY_FIRE)
    {
        VD_VALUE[playerid] += 10.0;
        if(VD_VALUE[playerid] >= 100.0)
        {
            TogglePlayerSpectating(playerid, 0);
            KillTimer(VD_TIMER[playerid]);
            VD_TIMER[playerid] = 0;
            TextDrawHideForPlayer(playerid, VD_BOX);
            TextDrawHideForPlayer(playerid, VD_BOX2);
            TextDrawHideForPlayer(playerid, VD_TEXT);
            HidePlayerProgressBar(playerid, VD_BAR[playerid]);
            SpawnPlayer(playerid);
            return 1;
        }
        SetPlayerProgressBarValue(playerid, VD_BAR[playerid], VD_VALUE[playerid]);
        return 1;
    }
    return 1;
}

This is pretty bad:
pawn Code:
if(VD_TIMER[playerid] < 1.0) return 1;

Firstly VD_TIMER is an integer not a decimal so you don't need this *.0. Besides, don't return 1, just execute the code if VD_TIMER is above 1 by doing it like this:
pawn Code:
if(VD_TIMER[playerid]) {
        //Your code here...
    }
1. Isnt needed anymore
2. im aware just didnt think people would merge it with their gm/fs (ik kinda stupid to think they wont)
3. OPU is too fast for the bar to update it sometimes appears empty but updated anyway
4. In GTA 5 you can click to fill the bar faster so ill keep it as i want it just like in GTA 5
5. It was actually meant to be VD_VALUE not TIMER my mistake but also now its not needed anymore anyway
__________________
Lokii is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] "Wasted" GTA V Style [ Death Style ] HY Filterscripts 29 02/12/2014 01:10 PM
Skins Walking style/Run style KaliKs Scripting Help 0 07/02/2014 12:35 PM
[ANNOUNCEMENT STYLE HELP] I need help fixing my announcement command style! lottoboy Scripting Help 9 15/10/2013 01:25 AM
[AJUDA] resapwn de um carro caoraivoso3 Português/Portuguese 4 04/04/2012 09:03 PM
[ONLINE-APP] Online SA-MP Tools ! ( Teleport, Vehicles, Functions, Color ... ) ! PhyroIS Filterscripts 12 13/11/2010 08:25 PM


All times are GMT. The time now is 01:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.