Raised This Month: $ Target: $400
 0% 

Editing strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-06-2013 , 08:41   Editing strings
Reply With Quote #1

I'm sending a string to the script:

PHP Code:
    char className[64] = "prop_dynamic";
    
int  iForceEdictIndex 1;

    
cell_t result Pl_Continue;
    
IForward->PushString(className);
    
IForward->PushCellByRef(&iForceEdictIndex);
    
IForward->Execute(&result);

//IForward= forwards->CreateForward("OnCreateEntity", ET_Event, 2, NULL, Param_String, Param_CellByRef); 
Then I change values:
PHP Code:
public Action:OnCreateEntity(String:className[], &iForceEdictIndex)
{
    
className[0] = 'a';
    
iForceEdictIndex+=1;
    return 
Plugin_Changed;    

As a result:
className = "prop_dynamic"
iForceEdictIndex = 2

Why is the first letter in the string is not changed? how can I change it?
kadet.89 is offline
Send a message via Skype™ to kadet.89
psychonic

BAFFLED
Join Date: May 2008
Old 10-06-2013 , 09:00   Re: Editing strings
Reply With Quote #2

You want to use PushStringEx (with the SM_PARAM_COPYBACK flag) instead of PushString if you want the script to be able to modify the source string.
psychonic is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 10-06-2013 , 10:35   Re: Editing strings
Reply With Quote #3

PushStringEx(classNameBuf, 64, SM_PARAM_COPYBACK, SM_PARAM_STRING_COPY);
is it correct? maybe I should do something else? It's still not working as it should

Last edited by kadet.89; 10-06-2013 at 10:35.
kadet.89 is offline
Send a message via Skype™ to kadet.89
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 23:27.


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