Jump to content

[CLEO] [SNIPPET] RemoveLastCaractersFromString


Tupi
 Share

Recommended Posts

Snippet:

:RemoveLastCaractersFromString
{
	0AB1: @RemoveLastCaractersFromString 2 OriginalString 0@ CaractersToBeDeleted 10 NewString 0@
}
0C17: 2@ = strlen 0@
0062: 2@ -= 1@  // (int)
0C24: strncpy destination 0@ source 0@ size 2@
ret 1 0@

 

Exemplu: 

{$CLEO}

0000:
repeat
wait 50
until 0AFA:

WHILE TRUE
WAIT 0
END

:command
SAMP.IsCommandTyped(0@)
chatmsg "Original string: %s" -1 0@
0AB1: @RemoveLastCaractersFromString 2 OriginalString 0@ Caracters 10 NewString 0@
chatmsg "New string: %s" -1 0@
SAMP.CmdRet

 

Explicația:

Snippet-ul sterge ultimele X caractere dintr-un anumit string, dupa care este returnat.

Acest snippet poate fi folosit intr-o multitudine de situații, când avem anumite caractere care nu ne intereseaza la final de string si vrem sa le eliminam din diferite motive.

Link to comment
Share on other sites

  • Tupi locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • 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.