AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Couple of questions to get me started. (https://forums.alliedmods.net/showthread.php?t=524)

Gor.d 03-26-2004 16:20

Couple of questions to get me started.
 
Hello everyone. I've decided to try my hand at learning how these plugins work and to maybe write a few (one day). I've read the tutorials from mod.net and some that I have found links to on this site.

The plugin that I am starting off with is the Say_BS plugin from f117bomb because it's really short.

Code:

/* AMXMOD script.
*
* (c) Copyright 2000-2002, f117bomb
* This file is provided as is (no warranties).
*
*/

#include <amxmod>

new phrase[4][] = { "bs", "bullshit", "bullsh*t", "hack"}

public say_event(id)
{
        new sid[10]
        num_to_str(id,sid,10)
        new said[192]
        read_args(said,191)
       
        for(new i = 0 ;i < 4; i += 1)
                if(containi(said,phrase[i]) != -1)
                        set_task(1.0,"client",0,sid,10)
}

public client(sid[])
{
        new id = str_to_num(sid)
        engclient_cmd(id,"say", "But then agian, I am a noob...")
}

public plugin_init()
{
        register_plugin("Say BS","0.3","f117bomb")
        register_clcmd("say","say_event")
        return PLUGIN_CONTINUE
}

Im trying to figure as much of this out on my own as I can so my question for now is what does the line "new sid[10]" do? What does sid mean, and what is the significance of the 10?

Thanks for the help.

Peli 03-26-2004 20:55

I read this and well it clarified a lot of things that I was confused about. I think you should read the part about strings and arrays. http://www.tcwonline.org/cgi-bin/vie...ish/scripting/ Just look over a few parts :)

Gor.d 03-26-2004 21:00

Thanks alot! I hadn't seen that before.

BigBaller 03-26-2004 21:04

It might also help if you used

#include <amxmodx>

considering you already made the changes for strtonum and numtostr which are str_to_num and num_to_str

:)

Peli 03-27-2004 03:14

No problem.

QwertyAccess 03-27-2004 03:39

SniperBeamer is really picky about that :-)

Gor.d 03-31-2004 17:06

Lol ok guys, laugh if you want. I have been hacking this little script left and right making it do all kinds of useless stuff. Here it is in it's current rendition.

Code:

/*
/Original cobe by f117bomb
/I just hacked it to pieces
*/


#include <amxmod>

new phrase[4][] = { "Ralph", "ralphy", "ralph", "ralphie"}

public say_event(id)
{
    new sid[10]
    num_to_str(id,sid,10)
    new said[192]
    read_args(said,191)

    for(new i = 0 ;i < 4; i += 1)
        if(containi(said,phrase[i]) != -1)
            set_task(1.0,"client",0,sid,10)
}

public client(sid[])
{
    new id = str_to_num(sid)
    give_item(id,"weapon_awp")
    give_item(id,"weapon_deagle")
    set_user_money(id,16000 ,1)
}

public plugin_init()
{
    register_plugin("RAWR","0.00001","Gordy")
    register_clcmd("say","say_event")
    return PLUGIN_CONTINUE
}

What I am trying to do now is remove the say triggers and change it to a console command.


Code:

/*
/Original cobe by f117bomb
/I just hacked it to pieces
*/


#include <amxmod>



public amx_gimme(id,level,cid)
{
    give_item(id,"weapon_awp")
    give_item(id,"weapon_deagle")
    set_user_money(id,16000 ,1)
}

public plugin_init()
{
    register_plugin("RAWR","0.00001","Gordy")
    register_clcmd("amx_gimme","amx_gimme",ADMIN_BAN,"My little secret")
    return PLUGIN_CONTINUE
}

It actually compiles without errors, but I can't test it yet. I'm pretty sure it won't work. Anyone care to give me a hint?

BTW: Just incase your curious, Ralph is my cat :)

BigBaller 03-31-2004 19:12

I think you might run into admin_immunity problems.

IceMouse[WrG] 03-31-2004 19:35

He doesn't do any checks, so it is unlikely he would...

Anyhow post the errors and ask as many questions as you need

Peli 03-31-2004 22:36

Sorry to take attention away from his post but one quick question. How would you give a player a weapon without taking his/her money?

BAILOPAN 03-31-2004 22:40

give_item("weapon_name")

eg
give_item("weapon_ak47")

Gor.d 03-31-2004 23:07

It works!! Haha and I think I know why it all works too.

Quote:

Originally Posted by IceMouse[WrG
]He doesn't do any checks, so it is unlikely he would...

Would it be better if I used checks? Or I guess I should say..what are they advantages of useing checks?

Peli 03-31-2004 23:19

Thank you Bail :)

MagicShot 04-01-2004 00:14

hrm?
 
Bail: Does this work?

give_item("sheild")

BAILOPAN 04-01-2004 00:32

give_item("weapon_shield") or weapon_shieldgun I forget

Peli 04-01-2004 03:09

Is it possible to give weapons without taking money from the user?

BAILOPAN 04-01-2004 03:10

yeah I just told you it =P that doesn't take money

Peli 04-01-2004 16:59

Oh okay thanks :)

Gor.d 04-01-2004 20:22

I am getting an "unknown command amx_gimme" in the console. It still works but gives that error. Does this have something to do with the checks that someone mentioned?

dragonchaos 04-01-2004 22:01

you have to add
Code:

return PLUGIN_HANDLED
at the end of your function amx_gimme


All times are GMT -4. The time now is 16:51.

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