Raised This Month: $ Target: $400
 0% 

[HELP] Creating a task


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kapitana
Member
Join Date: Apr 2014
Old 02-13-2016 , 08:47   [HELP] Creating a task
Reply With Quote #1

Hello Alliedmodders,
I'm in a little need of scripting help creating a task ...
So .. what I'm trying to do is a task that gets the victim, attacker and the damage taken.
Here is an example:

set_task(0.2, "create_task", id+TASK_DAMAGE, attacker, damage, _, _, "b")

But I get an error every time I try to compile. If someone knows how to fix it .... please share
Thanks in advance
kapitana is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 02-13-2016 , 09:05   Re: [HELP] Creating a task
Reply With Quote #2

It would help, if you post the exact error message and compile log.
__________________
Spirit_12 is offline
Old 02-13-2016, 09:07
dark_style
This message has been deleted by dark_style.
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-13-2016 , 09:12   Re: [HELP] Creating a task
Reply With Quote #3

Quote:
Originally Posted by kapitana View Post
Hello Alliedmodders,
I'm in a little need of scripting help creating a task ...
So .. what I'm trying to do is a task that gets the victim, attacker and the damage taken.
Here is an example:

set_task(0.2, "create_task", id+TASK_DAMAGE, attacker, damage, _, _, "b")

But I get an error every time I try to compile. If someone knows how to fix it .... please share
Thanks in advance
PHP Code:
native set_task(Float:time,const function[],id 0,const parameter[]="",len 0,const flags[]=""repeat 0); 
Because you can't send 2 arguments in this way , i mean attacker, damage. I tried myself once but it didn't work.You should use parameter[]="" instead, it's a string where you add your values .

So do this :

PHP Code:
new params[2]
param[0] =  attacker
param
[1] =  damage

set_task
(0.2"create_task"id+TASK_DAMAGEparams2__"b"
But damage shall be the same type as attacker , if it's float then you convert it to number :
damage = floatround(damage)

And then if you need damage as float, you just convert it back to float :

new Float:dmg = float(param[1])
siriusmd99 is offline
kapitana
Member
Join Date: Apr 2014
Old 02-13-2016 , 09:16   Re: [HELP] Creating a task
Reply With Quote #4

Yea ... that helps very much ... thnx siriusmd99
kapitana is offline
Old 02-13-2016, 09:17
safetymoose
This message has been deleted by safetymoose. Reason: nvm
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-13-2016 , 13:10   Re: [HELP] Creating a task
Reply With Quote #5

Quote:
Originally Posted by siriusmd99 View Post
But damage shall be the same type as attacker , if it's float then you convert it to number :
damage = floatround(damage)

And then if you need damage as float, you just convert it back to float :

new Float:dmg = float(param[1])
You don't have to convert it, it's okay just to re-tag the variable to avoid the compiler warning. Doing it your way you are even truncating the fractional part of a float value, which is a data loss.

PHP Code:
public Player_TakeDamage(idinflictorattackerFloatdamagedamagetype) {
    new 
params[2];
    
params[0] = attacker;
    
params[1] = _:damage;

    
set_task(0.2"create_task"id TASK_DAMAGEparamssizeof(params), __"b");
}

public 
create_task(params[], taskid) {
    new 
attacker params[0];
    new 
Floatdamage Floatparams[1];

I know it seems unnatural, and that tags in Pawn can be confusing. That's why we all hate tags.
klippy is offline
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 09:26.


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