AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Read_agv...Error? (https://forums.alliedmods.net/showthread.php?t=121864)

r4ndomz 03-20-2010 14:02

Read_agv...Error?
 
Hey, i was making my own version of amx_slap, and read_argv didnt work out to well for me.


PHP Code:

register_concmd("amx_ultslap""slap_cmd"ADMIN_BAN"- amx_ultslap <Victim> <Damage> <# of Slaps>"); 

PHP Code:

public slap_cmd(id)
{
    new 
arg[32], arg2arg3name[32], name2[32];

    
readargv(1arg31)
    
readargv(2arg20)
    
readargv(3arg30)

    
get_user_name(idname31)
    
get_user_name(idname231)

    for (new 
i=1i<=arg3i++)
    {
           
user_slap(argarg20);
    }

    
client_print(0print_chat"ADMIN: %s has slapped %s"namename2); 


What did i do wrong?

ConnorMcLeod 03-20-2010 14:05

Re: Read_agv...Error?
 
Quote:

Originally Posted by r4ndomz (Post 1123507)
What did i do wrong?

You try to do something too dificult for your level, please start with something easier.
All what is highlighted is wrong :

Code:
public slap_cmd(id) {     new arg[32], arg2, arg3, name[32], name2[32];     readargv(1, arg, 31)     readargv(2, arg2, 0)     readargv(3, arg3, 0)     get_user_name(id, name, 31)     get_user_name(id, name2, 31)     for (new i=1; i<=arg3; i++)     {            user_slap(arg, arg2, 0);     }     client_print(0, print_chat, "ADMIN: %s has slapped %s", name, name2); }

Arkshine 03-20-2010 14:27

Re: Read_agv...Error?
 
Read some tutorials there : http://wiki.amxmodx.org/Category:Scripting_(AMX_Mod_X)

r4ndomz 03-20-2010 15:04

Re: Read_agv...Error?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1123510)
You try to do something too dificult for your level, please start with something easier.
All what is highlighted is wrong :

Code:
public slap_cmd(id) { new arg[32], arg2, arg3, name[32], name2[32];
readargv(1, arg, 31)
readargv(2, arg2, 0)
readargv(3, arg3, 0)
get_user_name(id, name, 31) get_user_name(id, name2, 31)
for (new i=1; i<=arg3; i++)
{ user_slap(arg, arg2, 0);
} client_print(0, print_chat, "ADMIN: %s has slapped %s", name, name2);
}


Well i have to learn it at some point. Anyways what should i do with the highlighted text?

Arkshine 03-20-2010 15:08

Re: Read_agv...Error?
 
Read more tutorials, you will your errors fastly. Follow the link above.

r4ndomz 03-20-2010 15:35

Re: Read_agv...Error?
 
Ok, i went through this http://wiki.amxmodx.org/Intro_to_AMX_Mod_X_Scripting at the hp tutorial thing.

PHP Code:

register_concmd("amx_ultslap""slap_cmd"ADMIN_BAN"- amx_ultslap <Victim> <Damage> <# of Slaps>"); 

PHP Code:

public slap_cmd(idlevelcid)
{
    if (!
cmd_access(idlevelcid3))
        return 
PLUGIN_HANDLED

    
new arg[32], arg2[4], arg3[4], name[32];

    
readargv(1arg31)
    
readargv(2arg23)
    
readargv(3arg33)

    new 
targ cmd_target(idarg1);
    new 
amount str_to_num(arg2);
    new 
times str_to_num(arg3);

    
get_user_name(idname31)

    if(!
targ)
    {
        
console_print(id"Sorry, player %s could not be found or targetted!"arg)
        return 
PLUGIN_HANDLED
    
}
    else
    {
        for (new 
i=1i<=timesi++)
        {
               
user_slap(targamount0);
        }

        
client_print(0print_chat"ADMIN: %s has slapped %s %s times with %s damage"nameargtimesamount);
    }

    return 
PLUGIN_CONTINUE


PHP Code:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// allinone.sma
// C:\Documents and Settings\\Desktop\USB\compiler1\allinone.sma(48) : err
or 017undefined symbol "readargv"
// C:\Documents and Settings\\Desktop\USB\compiler1\allinone.sma(49) : err
or 017undefined symbol "readargv"
// C:\Documents and Settings\\Desktop\USB\compiler1\allinone.sma(50) : err
or 017undefined symbol "readargv"
//
// 3 Errors.
// Could not locate output file C:\Documents and Settings\\Desktop\USB\com
piler1\compiled\allinone.amx (compile failed).
//
// Compilation Time: 0.2 sec
// ----------------------------------------

Press enter to exit ... 



wrecked_ 03-20-2010 15:44

Re: Read_agv...Error?
 
Code:

read_argv

ConnorMcLeod 03-20-2010 16:10

Re: Read_agv...Error?
 
That's better.
You forgot to use cmd_target to retrieve the player index you want to slap.
Also, a for() loop won't do what you want to do because such a loop in done in an instant, means the player will be slapped 3 times at the exact same time.
You would have to set a task and use the flag "a" (repeat) in it with the number of slap ou want.

r4ndomz 03-20-2010 20:35

Re: Read_agv...Error?
 
Thanks connor, but how do i set the for loop to a?

Also, i feel so silly for readargv instead of read_argv, i remember searching read_argv on the func wiki and just feeling that mood where you want to scream WHAT THE HELL!! and wonder why it wasnt working LOL

Bugsy 03-20-2010 21:17

Re: Read_agv...Error?
 
Heres a hint

http://www.amxmodx.org/funcwiki.php?go=func&id=253

Just make sure id is the id of player you want to slap.
PHP Code:

new iData];
iData] = amount;
set_task0.75 "SlapPlayer" id iData sizeofiData ) , "a" times );

public 
SlapPlayeriData] , id )
{
    
user_slapid iData] , );




All times are GMT -4. The time now is 08:41.

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