Jump to content

Întrebare Sanny Builder.


Madalin

Recommended Posts

Doresc şi eu o comandă prin care să pot lua un anunţ random dintr-o listă şi să-l pot da printr-o altă comandă, de exemplu, într-un mod pentru News Reporters se putea da [/getrp] şi ia random un anunţ din câte anunţuri are modul respectiv şi cu [/giverp] se anunţa pe [/news].

 

Dau +1 :P

 

@shanker' 

Link to comment
Share on other sites

@Madalin,

 

:getNews
SAMP.IsCommandTyped(0@)
if 0AD4: 33@ = scan_string 0@ format "%d" 1@
then
    if 0AAB:   file_exists "CLEO\Anunturile-mele.txt"
    then      
        1@ += 1
        0209: 2@ = random_int_in_ranges 1 1@
        0AC8: 3@ = allocate_memory_size 666
        0AD3: 3@ = format "[Anuntul %d]" 2@
        
        4@ = File.Open("CLEO\Anunturile-mele.txt", "rt+")
        repeat
            wait 0
            
            0AC8: 5@ = allocate_memory_size 666
            File.ReadString(4@, 5@, 666)
            
            if or
                0C29: 6@ = stristr string1 3@ string2 5@
                0C29: 6@ = stristr string1 5@ string2 3@
            then
                File.ReadString(4@, 5@, 666)
                say 5@
                0AC9: free_allocated_memory 5@
                break
            end
            0AC9: free_allocated_memory 5@
        until File.EOF(4@)
        File.Close(4@)
        
    else chatmsg "Eroare - nu am putut gasi fisierul cu anunturi." -1
    end
else chatmsg "Introdu numarul de anunturi din fisierul cu anunturi" -1
end
0B43: samp cmd_ret

Fișierul cu anunțuri arată în felul următor:

image.thumb.png.1e46b2024f6ba0cb23cf3393a1fa0a52.png

 

Întrebarea este următoarea, anunțurile astea încap într-un singur rând pe /news? Sau tu vei adăuga doar anunțuri ce o să încapă într-un singur rând? Pot să fac și pe 2 rânduri, dar în momentul de față sunt cam brain dead ?

Link to comment
Share on other sites

13 hours ago, shanker' said:

@Madalin,

 


:getNews
SAMP.IsCommandTyped(0@)
if 0AD4: 33@ = scan_string 0@ format "%d" 1@
then
    if 0AAB:   file_exists "CLEO\Anunturile-mele.txt"
    then      
        1@ += 1
        0209: 2@ = random_int_in_ranges 1 1@
        0AC8: 3@ = allocate_memory_size 666
        0AD3: 3@ = format "[Anuntul %d]" 2@
        
        4@ = File.Open("CLEO\Anunturile-mele.txt", "rt+")
        repeat
            wait 0
            
            0AC8: 5@ = allocate_memory_size 666
            File.ReadString(4@, 5@, 666)
            
            if or
                0C29: 6@ = stristr string1 3@ string2 5@
                0C29: 6@ = stristr string1 5@ string2 3@
            then
                File.ReadString(4@, 5@, 666)
                say 5@
                0AC9: free_allocated_memory 5@
                break
            end
            0AC9: free_allocated_memory 5@
        until File.EOF(4@)
        File.Close(4@)
        
    else chatmsg "Eroare - nu am putut gasi fisierul cu anunturi." -1
    end
else chatmsg "Introdu numarul de anunturi din fisierul cu anunturi" -1
end
0B43: samp cmd_ret

Fișierul cu anunțuri arată în felul următor:

image.thumb.png.1e46b2024f6ba0cb23cf3393a1fa0a52.png

 

Întrebarea este următoarea, anunțurile astea încap într-un singur rând pe /news? Sau tu vei adăuga doar anunțuri ce o să încapă într-un singur rând? Pot să fac și pe 2 rânduri, dar în momentul de față sunt cam brain dead ?

Dacă poți, ?

Link to comment
Share on other sites

@Madalin,

 

Salut, am uitat de tine, am reușit să fac următorul sistem:

image.png.09009e9d486b4cb83419abe1f2db9097.png

 

Când dai /getnews „nr-anunturi total din fisier txt”, o să-ți apară anuntul, fie pe un rand, fie pe 2, în funcție de cum l-ai setat tu din fișierul text document.

 

Cum se face asta?

Ai exemplu aici:

image.thumb.png.6a4d4eb0ce766b80825aefc51760444b.png

 

Codul sursă (știi să-l compilezi singur?, daca nu, spune-mi):

{$CLEO}

0000:

repeat
    wait 0
until 0AFA:

0B63: samp unregister_client_command "getNews"
0B63: samp unregister_client_command "putNews"
0B34: samp register_client_command "getNews" to_label @getNews
0B34: samp register_client_command "putNews" to_label @putNews


Alloc 25@ = 1000
Alloc 26@ = 1000

while true
    wait 0 
    
    if 15@ == 1
    then
        15@ = 0
        if 0AAB:   file_exists "CLEO\Anunturi.txt"
        then      
            1@ += 1
            0209: 2@ = random_int_in_ranges 1 1@
            0AC8: 3@ = allocate_memory_size 666
            0AD3: 3@ = format "[Anuntul %d]" 2@
            
            chatmsg "{e8b72e}Anuntul %d" -1 2@
            4@ = File.Open("CLEO\Anunturi.txt", "rt+")
            repeat
                wait 0
                Alloc 5@ = 600
                File.ReadString(4@, 5@, 600)
                
                if 0C29: 33@ = stristr string1 5@ string2 3@
                then 
                    File.ReadString(4@, 5@, 600)
                    if or
                        0C29: 33@ = stristr string1 5@ string2 "Randuri]"
                        0C29: 33@ = stristr string1 5@ string2 "Randuri"
                    then
                        Alloc 6@ = 600
                        File.ReadString(4@, 5@, 600)
                        File.ReadString(4@, 6@, 600)
                        0AD3: 25@ = format "%s" 5@
                        0AD3: 26@ = format "%s" 6@
                        chatmsg 25@ -1
                        chatmsg 26@ -1
                        Free 6@
                        27@ = 2
                    else 
                        27@ = 1
                        0AD3: 25@ = format "%s" 5@
                        chatmsg 25@ -1
                    end
                end
                
                Free 5@
            until File.EOF(4@)
            File.Close(4@)
            
            0AC9: free_allocated_memory 3@
            
        else chatmsg "Eroare - nu am putut gasi fisierul cu anunturi." -1
        end   
    end
end

:getNews
SAMP.IsCommandTyped(0@)
if 0AD4: 33@ = scan_string 0@ format "%d" 1@
then 15@ = 1
else chatmsg "Introdu numarul de anunturi din fisierul cu anunturi" -1
end
0B43: samp cmd_ret

:putNews
IF 27@ == 1
then say "/news %s" 25@
else 
    say "/news %s" 25@
    say "/news %s" 26@
end
0B43: samp cmd_ret

 

Link to comment
Share on other sites

1 hour ago, shanker' said:

@Madalin,

 

Salut, am uitat de tine, am reușit să fac următorul sistem:

image.png.09009e9d486b4cb83419abe1f2db9097.png

 

Când dai /getnews „nr-anunturi total din fisier txt”, o să-ți apară anuntul, fie pe un rand, fie pe 2, în funcție de cum l-ai setat tu din fișierul text document.

 

Cum se face asta?

Ai exemplu aici:

image.thumb.png.6a4d4eb0ce766b80825aefc51760444b.png

 

Codul sursă (știi să-l compilezi singur?, daca nu, spune-mi):


{$CLEO}

0000:

repeat
    wait 0
until 0AFA:

0B63: samp unregister_client_command "getNews"
0B63: samp unregister_client_command "putNews"
0B34: samp register_client_command "getNews" to_label @getNews
0B34: samp register_client_command "putNews" to_label @putNews


Alloc 25@ = 1000
Alloc 26@ = 1000

while true
    wait 0 
    
    if 15@ == 1
    then
        15@ = 0
        if 0AAB:   file_exists "CLEO\Anunturi.txt"
        then      
            1@ += 1
            0209: 2@ = random_int_in_ranges 1 1@
            0AC8: 3@ = allocate_memory_size 666
            0AD3: 3@ = format "[Anuntul %d]" 2@
            
            chatmsg "{e8b72e}Anuntul %d" -1 2@
            4@ = File.Open("CLEO\Anunturi.txt", "rt+")
            repeat
                wait 0
                Alloc 5@ = 600
                File.ReadString(4@, 5@, 600)
                
                if 0C29: 33@ = stristr string1 5@ string2 3@
                then 
                    File.ReadString(4@, 5@, 600)
                    if or
                        0C29: 33@ = stristr string1 5@ string2 "Randuri]"
                        0C29: 33@ = stristr string1 5@ string2 "Randuri"
                    then
                        Alloc 6@ = 600
                        File.ReadString(4@, 5@, 600)
                        File.ReadString(4@, 6@, 600)
                        0AD3: 25@ = format "%s" 5@
                        0AD3: 26@ = format "%s" 6@
                        chatmsg 25@ -1
                        chatmsg 26@ -1
                        Free 6@
                        27@ = 2
                    else 
                        27@ = 1
                        0AD3: 25@ = format "%s" 5@
                        chatmsg 25@ -1
                    end
                end
                
                Free 5@
            until File.EOF(4@)
            File.Close(4@)
            
            0AC9: free_allocated_memory 3@
            
        else chatmsg "Eroare - nu am putut gasi fisierul cu anunturi." -1
        end   
    end
end

:getNews
SAMP.IsCommandTyped(0@)
if 0AD4: 33@ = scan_string 0@ format "%d" 1@
then 15@ = 1
else chatmsg "Introdu numarul de anunturi din fisierul cu anunturi" -1
end
0B43: samp cmd_ret

:putNews
IF 27@ == 1
then say "/news %s" 25@
else 
    say "/news %s" 25@
    say "/news %s" 26@
end
0B43: samp cmd_ret

 

O să-l încerc mâine, mulțumesc! ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.