Raised This Month: $32 Target: $400
 8% 

show last 10 line


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SoccerjamTR
Member
Join Date: May 2021
Old 11-22-2022 , 07:30   show last 10 line
Reply With Quote #1

PHP Code:
public pShowNames(uIndex){
    new 
bmMotd[1680],bmAnlat;
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<head><style>table,th,td { border: 1px solid green;color:white; } td { width:100% }</style></head>");
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<center><ul>");    
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<span></span>")
    new 
lTotal ArraySize(gNames),lSearchForName[128],lGetTime[128];
    if(
lTotal){
        for(new 
ilTotali++){
            
ArrayGetString(gNames,i,lSearchForName,charsmax(lSearchForName));
            
ArrayGetString(gDates,i,lGetTime,charsmax(lGetTime));
            
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<li>%s %s</li>",lSearchForName,lGetTime);
        }    
    }
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"</ul><center>");
    
show_motd(uIndex,bmMotd,"");

This is motd show plugin but after 10 lines, lines don't fit on screen and i want to show last 10 lines. Player when open motd, shows 10 lines and this 10 line will be last lines. I want only the last 10 lines to appear when players open motd. Example if there is 30 lines, only last 10 line shows.

Last edited by SoccerjamTR; 11-22-2022 at 07:33.
SoccerjamTR is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 11-22-2022 , 08:10   Re: show last 10 line
Reply With Quote #2

Something like this?
PHP Code:
    if(lTotal){
        for(new 
lTotal=> lTotal 10i--){
            
ArrayGetString(gNames,i,lSearchForName,charsmax(lSearchForName));
            
ArrayGetString(gDates,i,lGetTime,charsmax(lGetTime));
            
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<li>%s %s</li>",lSearchForName,lGetTime);
        }    
    } 
Or this:
PHP Code:
    if(lTotal){
        for(new 
lTotal 10<= lTotali++){
            
ArrayGetString(gNames,i,lSearchForName,charsmax(lSearchForName));
            
ArrayGetString(gDates,i,lGetTime,charsmax(lGetTime));
            
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<li>%s %s</li>",lSearchForName,lGetTime);
        }    
    } 
Also you could do some refactoring and use add(); native:
PHP Code:
public pShowNames(uIndex) {
    new 
szMotd[MAX_MOTD_LENGTH];
    
    
add(szMotdcharsmax(szMotd), "<head><style>table,th,td { border: 1px solid green;color:white; } td { width:100% }</style></head>"); // Minimize?
    
add(szMotdcharsmax(szMotd), "<center><ul>");
    
//add(szMotd, charsmax(szMotd), "<span></span>"); // you can omit this container because you don't use it
    
    
new iTotal ArraySize(gNames);
    
    if(
iTotal) {
        new 
szBuffer[32 128];
        
// Player name max size is 32 characters + I'm sure the date you store there is much lesser than 128 characters
        
new szName[32], lGetTime[128];
        
        for(new 
iTotal 10<= iTotali++) {
            
ArrayGetString(gNamesiszNamecharsmax(szName));
            
ArrayGetString(gDatesilGetTimecharsmax(lGetTime));
            
formatex(szBuffercharsmax(szBuffer), "<li>%s %s</li>"szNamelGetTime);
            
add(szMotdcharsmax(szMotd), szBuffer);
        }
    }
    
    
add(szMotdcharsmax(szMotd), "</ul></center>");
    
show_motd(uIndexszMotd"");

Plus you need to learn some more html basics

I think this is none of my business but do you make table or list? I could help you if needed
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 11-23-2022 at 08:33.
kww is offline
SoccerjamTR
Member
Join Date: May 2021
Old 11-22-2022 , 16:37   Re: show last 10 line
Reply With Quote #3

i tried both but it gave error.
PHP Code:
Invalid cellvector handle provided (9:10:10)
[
AMXXDisplaying debug trace (plugin "g.amxx")
[
AMXXRun time error 10native error (native "ArrayGetString")
[
AMXX]    [0g.sma::pShowNames (line 15321
also i tried your full code. It gives same error.

Last edited by SoccerjamTR; 11-22-2022 at 16:40.
SoccerjamTR is offline
SoccerjamTR
Member
Join Date: May 2021
Old 12-07-2022 , 07:22   Re: show last 10 line
Reply With Quote #4

These are nvault codes
PHP Code:
public plugin_init() 
{
        
gNames ArrayCreate(512);
    
gDates ArrayCreate(512);
    
get_time("(%H.%M-%d.%m)",gDateNow,charsmax(gDateNow));
    new 
lKey[16],lCountNames;
    
formatex(lKey,charsmax(lKey),"TotalName");
    
lCountNames nvault_get(cVault,lKey);

    if(
lCountNames){
    new 
lGetName[32],lGetDate[32];
    for(new 
ilCountNamesi++){
    
formatex(lKey,charsmax(lKey),"%i-Name",i);
    
nvault_get(cVault,lKey,lGetName,charsmax(lGetName));
    
ArrayPushString(gNames,lGetName);
    
formatex(lKey,charsmax(lKey),"%i-Time",i);
    
nvault_get(cVault,lKey,lGetDate,charsmax(lGetDate));
    
ArrayPushString(gDates,lGetDate);
    }
}

SoccerjamTR is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 12-07-2022 , 11:53   Re: show last 10 line
Reply With Quote #5

maybe you surpassed character limit.
at the end of the function pShowNames run this code
client_print(uIndex, "%d", bmAnlat)
it'll print how many characters you've used.
__________________

Last edited by bigdaddy424; 12-07-2022 at 11:53. Reason: id to uIndex
bigdaddy424 is offline
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

Forum Jump


All times are GMT -4. The time now is 03:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode