SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 05/05/2017, 03:46 PM   #1
fatlirmorina
Big Clucker
 
Join Date: Nov 2013
Posts: 70
Reputation: 1
Default 5 latest deaths/cmds/advs?

Is there any way like I can script the latest 5 deaths just like on death-tab? Textdraws etc.
fatlirmorina is offline   Reply With Quote
Old 05/05/2017, 03:48 PM   #2
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 579
Reputation: 134
Default Re: 5 latest deaths/cmds/advs?

Yes, you can.
iLearner is offline   Reply With Quote
Old 05/05/2017, 03:53 PM   #3
fatlirmorina
Big Clucker
 
Join Date: Nov 2013
Posts: 70
Reputation: 1
Default Re: 5 latest deaths/cmds/advs?

Can you give me an example? 'scripting help'
fatlirmorina is offline   Reply With Quote
Old 05/05/2017, 04:24 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,066
Reputation: 2660
Default Re: 5 latest deaths/cmds/advs?



Your original question has two possible answers: yes and no. What you meant to ask was how or what. And in that case the answer would be: create a global two-dimensional array like "gJoins[5][MAX_PLAYER_NAME]".

If the new entry is to be added at the end of the list you first shift the array downwards in order to free the last slot, thereby discarding entry in the first slot. Then you write the new entry in slot 4. If you want to to add the new entry to the beginning of the list then you do the opposite. You shift everything upwards to free the first slot, thereby discarding the item in the last slot.

PHP Code:
new gJoins[5][MAX_PLAYER_NAME];

// shift down, discard first item
for(new isizeof(gJoins) - 1i++)
{
    
gJoins[i] = gJoins[1];
}

// write in the last slot (sizeof is 5, meaning the last slot is 5 - 1 = 4)
GetPlayerName(playeridgJoins[sizeof(gJoins) - 1], sizeof(gJoins[]));

// reshow the entire thing here 
I don't know if it will work exactly like that because I'm unable to test it right now. But that's the theory.
__________________
Vince is offline   Reply With Quote
Old 05/05/2017, 06:40 PM   #5
Freaksken
Gangsta
 
Freaksken's Avatar
 
Join Date: Mar 2009
Location: Belgium
Posts: 506
Reputation: 368
Default Re: 5 latest deaths/cmds/advs?

Quote:
Originally Posted by Vince View Post
...
And in that case the answer would be: create a global two-dimensional array like "gJoins[5][MAX_PLAYER_NAME + 1]".
...
For null terminator.
__________________
Always keep in mind that a lot of people are active on this forum in their spare time.
They are sacrificing time they could easily spend on things they would rather do, to help you instead.


[Include] FCNPC A.I. - [Tutorial] Speedometer - [WIP] Single-player-like co-op mission - [Other] List of all my work
Freaksken 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
return SendClientMessage(playerid, COLOR_RED, "ERROR : Unkown Command Use /cmds To The Cool Cmds ...... don't show :9 misho1 Help Archive 33 20/05/2011 03:57 PM
[FilterScript] [FS]RegServ, saves kills/deaths/money/wantedlvl/level & stats + some Xadmin cmds SmartyPants Filterscripts 33 21/12/2010 04:16 PM
[FilterScript] Health & armour cmds [6 cmds] Shockey Filterscripts 6 09/09/2010 06:12 PM


All times are GMT. The time now is 12:59 AM.


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