Raised This Month: $12 Target: $400
 3% 

Passing string to CreateTimer Function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marco811
New Member
Join Date: Jul 2019
Old 07-24-2019 , 15:03   Passing string to CreateTimer Function
Reply With Quote #1

Hello. I have this error: error 035: argument type mismatch (argument 3)

I am trying to pass a string variable to the createTimer function.


Code:
new String:steamid[25];
	
if(GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid))) {
	CreateTimer(2.0, saveBan, steamid);
}

public Action saveBan(Handle timer, any steamid) {
.......
}
This method does not work either: (now this error: error 100: function prototypes do not match)

Not working:
Code:
public Action saveBan(Handle timer, char[] steamid) {
.........
}
Not working:
( error 100: function prototypes do not match)
Code:
public Action saveBan(Handle timer, const char[] steamid) {
........
}
What is the solution? I am confused! Thanks
marco811 is offline
Wyon
Junior Member
Join Date: Mar 2018
Old 07-24-2019 , 15:25   Re: Passing string to CreateTimer Function
Reply With Quote #2

https://wiki.alliedmods.net/Timers_(...ng)#Data_Packs
Wyon is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-24-2019 , 16:30   Re: Passing string to CreateTimer Function
Reply With Quote #3

My question is why are you waiting 2 seconds to save a ban?

Sounds like an XY problem.
__________________
Neuro Toxin is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-24-2019 , 23:00   Re: Passing string to CreateTimer Function
Reply With Quote #4

https://sm.alliedmods.net/new-api/timers/Timer

The second parameter must be any, Handle, or simply absent. Who told you that char[] would work?
__________________
ddhoward is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 07-30-2019 , 13:43   Re: Passing string to CreateTimer Function
Reply With Quote #5

You could use GetSteamAccountID (int) instead.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 08-05-2019 , 15:01   Re: Passing string to CreateTimer Function
Reply With Quote #6

It does not work because it needs to be:
PHP Code:
public Action TimerCallback(Handle timerHandle hndlany data*);

This is not neededjust use Handle timerHandle hndl
// any data is some info stored on the action you created the timer. 
Best Regards, Hope I could help you ;)
__________________

Last edited by SpirT; 08-05-2019 at 15:02.
SpirT is offline
lugui
Senior Member
Join Date: Feb 2016
Location: GetClientAbsOrigin();
Old 08-09-2019 , 08:13   Re: Passing string to CreateTimer Function
Reply With Quote #7

the prototype does not match, the function expects a variable, not a array
__________________
Add me for commissions!
Steam: [U:1:88621772]
Discord: lugui#0889
My Plugins
lugui is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 08-09-2019 , 08:49   Re: Passing string to CreateTimer Function
Reply With Quote #8

Maybe there is more efficient method, but this should work

PHP Code:
#define STEAMID_CHARSTR_LENGTH 25

...(...)
{
    
char steamid[STEAMID_CHARSTR_LENGTH];
    if(
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid))) 
    {
        
DataPack pack;
        
        
CreateDataTimer(2.0saveBanpack);
        
        for(
int i 0STEAMID_CHARSTR_LENGTH; ++i)
        {
            
pack.WriteCell(view_as<int>(steamid[i]));
        }
    }
}
public 
Action saveBan(Handle timerDataPack pack
{
    
pack.Reset();
    
char steamid[STEAMID_CHARSTR_LENGTH];
    for(
int i 0STEAMID_CHARSTR_LENGTH; ++i)
    {
        
steamid[i] = view_as<char>(pack.ReadCell());
    }
    
    
//done

__________________
impossible_cc is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-09-2019 , 18:16   Re: Passing string to CreateTimer Function
Reply With Quote #9

Quote:
Originally Posted by impossible_cc View Post
Maybe there is more efficient method
https://sm.alliedmods.net/new-api/da...ck/WriteString
__________________
asherkin 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 11:50.


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