Raised This Month: $ Target: $400
 0% 

removing letter from begining of string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 01-21-2009 , 21:27   removing letter from begining of string
Reply With Quote #1

lets say

szstring[32] = "I Love Apples"

how can i remove the first 2 characters in that string and make it become

szstring[32] = "Love Apples"

i know this is a poor examples i just need to learn how to remove the first to characters in a string
whosyourdaddy is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-21-2009 , 21:43   Re: removing letter from begining of string
Reply With Quote #2

Code:
client_print(id,print_chat,"String: %s",szstring[0]);
Would actually print "Love Apples".

To remove it, I'm not positive but maybe.
Code:
 sztring[0] = "" // This might actually set the whole string to nothing or string[0] &= ""
or (probably not a good way)
Code:
format(sztring,31,"%s",szstring[0]);
__________________
Oh yeah

Last edited by Drak; 01-21-2009 at 21:46.
Drak is offline
Send a message via MSN to Drak
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-21-2009 , 21:51   Re: removing letter from begining of string
Reply With Quote #3

Quote:
Originally Posted by whosyourdaddy View Post
lets say

szstring[32] = "I Love Apples"

how can i remove the first 2 characters in that string and make it become

szstring[32] = "Love Apples"

i know this is a poor examples i just need to learn how to remove the first to characters in a string
If you just want to return that portion of the string starting at Love, use szstring[2] instead of szstring.

to actually remove it from the string
format( szstring, 32, "%s" , szstring[2])
__________________
Bugsy is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 01-21-2009 , 21:54   Re: removing letter from begining of string
Reply With Quote #4

ok now im using a for loop and all is there a way i can do a for loop and after every loop it will wait .5 seconds or something before doing another loop?

Last edited by whosyourdaddy; 01-21-2009 at 21:59.
whosyourdaddy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-22-2009 , 00:01   Re: removing letter from begining of string
Reply With Quote #5

Quote:
Originally Posted by whosyourdaddy View Post
ok now im using a for loop and all is there a way i can do a for loop and after every loop it will wait .5 seconds or something before doing another loop?
No, but you can use a task with a variable as an index which can simulate a for-loop. The below code should simulate this for-loop.
PHP Code:
for( new iIndex START_VALiIndex<= END_VALiIndex++)
{
    
//your code
    
Pause 0.5

I have not tested it but something like below can simulate a for-loop with a timeout.

PHP Code:
new param[2];
param[0] = START_VAL;
param[1] = END_VAL;

set_task0.5 "YourCode" 5555 param "b"); 
PHP Code:
public YourCode(param[2])
{
    static 
iIndex;

    if( 
iIndex param[0] )
        
iIndex param[0];

    
// your code here

    
if( iIndex == param[1] )
        
remove_task5555 );
    else
        
iIndex++;

__________________

Last edited by Bugsy; 01-22-2009 at 00:17.
Bugsy is offline
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 01-22-2009 , 00:37   Re: removing letter from begining of string
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
PHP Code:
for( new iIndex START_VALiIndex<= END_VALiIndex++)
{
    
//your code
    
Pause 0.5

so the pause 0.5 will work for sure in a for loop?
whosyourdaddy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-22-2009 , 00:44   Re: removing letter from begining of string
Reply With Quote #7

Quote:
Originally Posted by whosyourdaddy View Post
so the pause 0.5 will work for sure in a for loop?
No, I was giving you an example of what the code below that would simulate.

To start your for-loop, do this

PHP Code:
new param[2];
param[0] = START_VAL;
param[1] = END_VAL;

//This will start a 'loop' with 0.5 seconds between iterations.
set_task0.5 "YourCode" 5555 param "b"); 
Put your for-loop code in here:
PHP Code:
public YourCode(param[2])
{
    static 
iIndex;

    if( 
iIndex param[0] )
        
iIndex param[0];

    
// your for-loop code here

    
if( iIndex == param[1] )
        
remove_task5555 );
    else
        
iIndex++;

__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-22-2009 , 01:40   Re: removing letter from begining of string
Reply With Quote #8

Quote:
Originally Posted by whosyourdaddy View Post
so the pause 0.5 will work for sure in a for loop?
If you do not understand my code or what I am explaining, post what you have so far and what you are trying to do and I will try to write it for you.
__________________
Bugsy is offline
Old 01-22-2009, 00:12
Bugsy
This message has been deleted by Bugsy. Reason: double post
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 01-22-2009 , 01:34   Re: removing letter from begining of string
Reply With Quote #10

copy( some_new_variable, some_new_variables_len, szstring[2] )
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Reply



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 01:41.


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