AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help out for newbie (https://forums.alliedmods.net/showthread.php?t=293270)

Lawnmoverman 01-27-2017 16:52

Help out for newbie
 
Hi guys excuse me for my noob questions, but Im still learning.

So I have this code:

Code:

// (c)Lawnmoverman - nozgaming.eu

#include <amxmodx>
#include <amxmisc>

public plugin_init() {
register_plugin("Amx_banss","1.0","Lawnmoverman")
register_concmd("amx_banss","amx_banss",ADMIN_IMMUNITY)
}

public amx_banss(id) {
if (!(get_user_flags(id)&ADMIN_LEVEL_A)) {
console_print(id,"[AMXX] You do not have access to this command.")
return PLUGIN_HANDLED
}

new temp[32]
read_argv(1,temp,31)
new hacker_id = cmd_target(id, temp)
if(!hacker_id) {
return PLUGIN_HANDLED
}

new steamid[32]
read_argv(1,steamid,31)
new steam_id = get_user_authid(id,steamid,charsmax(steamid))
if(!steam_id){
return PLUGIN_HANDLED       
}

set_task(5.0, "task0", hacker_id)
set_task(5.1, "task1", hacker_id)
set_task(6.0, "task2", hacker_id)
set_task(7.0, "task3", hacker_id)
set_task(8.0, "task4", hacker_id)
set_task(10.0, "task5", hacker_id)
set_task(11.0, "task6", hacker_id)
set_task(13.0, "task7", hacker_id)

return PLUGIN_HANDLED
}

public task1(id) {
client_cmd(id, "snapshot;")
}

public task2(id) {
client_cmd(id, "snapshot;")
}

public task3(id) {
client_cmd(id, "play noz_welcome.wav;")
}

public task4(id) {
server_cmd("amx_shake %s", hacker_id)
}

public task5(id) {
client_cmd(id, "play noz_im_in_trouble.wav;")
server_cmd("amx_csay red %s have been banned!", hacker_id)
}

public task6(id) {
server_cmd("amx_ejectcd %s", hacker_id)
}

public task7(id) {
server_cmd("amx_ban %s 14400 http://www.nozgaming.eu/unban.html", steam_id)
}

public task0(id) {
client_print(id, print_chat, "cs.nozgaming.eu -->")
client_print(id, print_chat, "[BANSS] You are being owned!")
client_print(id, print_chat, "[BANSS] Visit http://www.nozgaming.eu, to ask unban!")
client_print(id, print_chat, "[NAME] $s [AUTHID] $s", hacker_id, steam_id)
client_print(id, print_chat, "<-- cs.nozgaming.eu")
}

And I cant get it to work. Compiler says:

Code:

.sma(56) error 017 undefined symbol "hacker_id"
.sma(61) error 017 undefined symbol "hacker_id"
.sma(65) error 017 undefined symbol "hacker_id"
.sma(69) error 017 undefined symbol "steam_id"
.sma(76) error 017 undefined symbol "hacker_id"
.sma(76) error 017 undefined symbol "steam_id"

Someone please help me to get this working. Sorry but Im stuck!

EFFx 01-27-2017 17:03

Re: Help out for newbie
 
Thats because the hacker_id and steam_id doesn't exists on their respectives functions. Just change they to 'id'

And don't use so much tasks together, they can fail sometimes. And i've see that all tasks just have one second of difference, so you can use like this:

PHP Code:

set_task(1.0,"function",id, . flags "a", .repeat 7

Here:

PHP Code:

register_concmd("amx_banss","amx_banss",ADMIN_IMMUNITY

PHP Code:

public amx_banss(id) {
if (!(
get_user_flags(id)&ADMIN_LEVEL_A)) { 
console_print(id,"[AMXX] You do not have access to this command.")
return 
PLUGIN_HANDLED


Do not do this, the command access is after the function on register_concmd hook (ADMIN_IMMUNITY), just add

PHP Code:

    if(!cmd_access(id,level,cid,1))
        return 
PLUGIN_HANDLED 

That will check if the admin have the command access that you've added on the hook.

Here:

PHP Code:

new steamid[32]
read_argv(1,steamid,31)
new 
steam_id get_user_authid(id,steamid,charsmax(steamid))
if(!
steam_id){
return 
PLUGIN_HANDLED    


You're not using this, so it can be removed, there's no sense.

Here:

PHP Code:

new temp[32
read_argv(1,temp,31
new 
hacker_id cmd_target(idtemp)
if(!
hacker_id) {
return 
PLUGIN_HANDLED


You can rename these strings for readers understand whats is this.

Here:

PHP Code:

public client_disconnect(id)
{
    if(
task_exists(id+TASK_BAN))
    {
        
BanPlayer(id)
        
remove_task(id+TASK_BAN)
    }


I'm checking if the player has disconnect when you've used the ban command on him and it makes him be banned. Because he can retry after command you use.

Here:

PHP Code:

client_print(idprint_chat"cs.nozgaming.eu -->")
client_print(idprint_chat"[BANSS] You are being owned!")
client_print(idprint_chat"[BANSS] Visit http://www.nozgaming.eu, to ask unban!")
client_print(idprint_chat"[NAME] $s [AUTHID] $s"hacker_idsteam_id)
client_print(idprint_chat"<-- cs.nozgaming.eu"

If you're using numbers ( the id ), use %d, if you're using strings (letters, names, etc..), like the UserName use %s

If you want to add a phrase on the reason, like amx_ban EFFx 60 He is cheating, you should add ^" ^" on the message, will be like

Code:

amx_ban EFFx 60 ^"He is cheating^"
Because the command amx_ban will think that He is Cheating are parameters. But it isn't.

Will be something similar at this:

PHP Code:

#include <amxmodx>
#include <amxmisc>

new iCount =        0
const TASK_BAN =    35103013

public plugin_init() 
{
    
register_plugin("Amx_banss","1.0","Lawnmoverman")
    
register_concmd("amx_banss","amx_banss",ADMIN_IMMUNITY"<name>")
}

public 
client_disconnect(id)
{
    if(
task_exists(id+TASK_BAN))
    {
        
BanPlayer(id)
        
remove_task(id+TASK_BAN)
    }
}

public 
amx_banss(idlevelcid
{
    if(!
cmd_access(id,level,cid,2))
        return 
PLUGIN_HANDLED
    
    
new szTarget[32
    
read_argv(1,szTargetcharsmax(szTarget)) 
    
    new 
targetID cmd_target(idszTarget)
    if(!
targetID
        return 
PLUGIN_HANDLED
    
    iCount 
0
    
    set_task
(1.0"task"targetID+TASK_BAN, .flags "a", .repeat 7)
    return 
PLUGIN_HANDLED
}

public 
task(id
{
    
id -= TASK_BAN
    
    
new UserName[32]
    
get_user_name(idUserNamecharsmax(UserName))

    switch(
iCount)
    {
        case 
01client_cmd(id"snapshot")
        case 
2client_cmd(id"spk noz_welcome.wav")
        case 
3server_cmd("amx_shake ^"%s^""id)
        case 
4:
        {
            
client_cmd(id"play noz_im_in_trouble.wav")
            
server_cmd("amx_csay red ^"%s have been banned!^""UserName)
        }
        case 
5:    server_cmd("amx_ejectcd ^"%s^""id)
        case 
6BanPlayer(id)
    }
    
iCount++
}

BanPlayer(idUserName[])
{
    
client_print(idprint_chat"cs.nozgaming.eu -->")
    
client_print(idprint_chat"[BANSS] You are being owned!")
    
client_print(idprint_chat"[BANSS] Visit http://www.nozgaming.eu, to ask unban!")
    
client_print(idprint_chat"[NAME] %s [AUTHID] %d"UserNameid)
    
client_print(idprint_chat"<-- cs.nozgaming.eu")
    
server_cmd("amx_ban %s 14400 ^"http://www.nozgaming.eu/unban.html^"", id)



Lawnmoverman 01-27-2017 17:46

Re: Help out for newbie
 
This is skill.! You have totally optimized everything. I will try it tommorow, repeat set_task I can use only for snapshots, I need specified time for other cases because of effects and sound lenght. Why you use spk in case 2?

EFFx 01-27-2017 17:52

Re: Help out for newbie
 
I had a code like this aswell and a guy told me to use a function like that:

PHP Code:

new const Float:fTime[] = { 1.01.13.05.010.013.0 }

set_task(fTime[iCounts], "function"bla bla bla

I think is something like this.

And you can use both of formats on case 2, play or spk are the same.

Edit: Sorry, I've added 5.0 on set_task(), It should be 1.0.

Lawnmoverman 01-28-2017 06:06

Re: Help out for newbie
 
I edited this like this:

PHP Code:

#include <amxmodx>
#include <amxmisc>

new iCount =        0
const TASK_BAN =    35103013

public plugin_init() 
{
    
register_plugin("Amx_banss","1.0","Lawnmoverman")
    
register_concmd("amx_banss","amx_banss",ADMIN_IMMUNITY"<name>")
}

public 
client_disconnect(id)
{
    if(
task_exists(id+TASK_BAN))
    {
        
BanPlayer(id)
        
remove_task(id+TASK_BAN)
    }
}

public 
amx_banss(idlevelcid
{
    if(!
cmd_access(id,level,cid,2))
        return 
PLUGIN_HANDLED
    
    
new szTarget[32
    
read_argv(1,szTargetcharsmax(szTarget)) 
    
    new 
targetID cmd_target(idszTarget)
    if(!
targetID
        return 
PLUGIN_HANDLED
    
    iCount 
0
    
//    set_task(1.0, "task", targetID+TASK_BAN, .flags = "a", .repeat = 7)

    
new const Float:fTime[] = { 0.52.53.04.08.09.012.0 }
    
set_task(fTime[iCount], "task"targetID+TASK_BAN)

    return 
PLUGIN_HANDLED
}

public 
task(id
{
    
id -= TASK_BAN
    
    
new UserName[32]
    
get_user_name(idUserNamecharsmax(UserName))

    switch(
iCount)
    {
        case 
01client_cmd(id"snapshot")
        case 
2client_cmd(id"play noz_welcome.wav")
        case 
3server_cmd("amx_shake ^"%s^""id)
        case 
4:
        {
            
client_cmd(id"spk noz_im_in_trouble.wav")
            
server_cmd("amx_csay red ^"%s have been banned!^""UserName)
        }
        case 
5server_cmd("amx_ejectcd ^"%s^""id)
        case 
6BanPlayer(id)
    }
    
iCount++
}

BanPlayer(idUserName[])
{
    
client_print(idprint_chat"cs.nozgaming.eu -->")
    
client_print(idprint_chat"[BANSS] You are being owned!")
    
client_print(idprint_chat"[BANSS] Visit http://www.nozgaming.eu, to ask unban!")
    
client_print(idprint_chat"[NAME] %s [AUTHID] %d"UserNameid)
    
client_print(idprint_chat"<-- cs.nozgaming.eu")
    
server_cmd("amx_ban %s 14400 ^"Visit http://www.nozgaming.eu to ask unban!^"", id)


The compiler gives me 088 number of arguments does not match definition on line 17 and line 62 both for:

PHP Code:

BanPlayer(id

Can you please check it out.

HamletEagle 01-28-2017 06:11

Re: Help out for newbie
 
Look how your function looks and how you call it. Also try to understand the error message. It clearly says that the number of arguments is wrong.

Lawnmoverman 01-28-2017 10:03

Re: Help out for newbie
 
I think that I got it but as I dont know well this programming language I completely eliminated username. But after compiling it doesnt work. I think that problem is here:
PHP Code:

new const Float:fTime[] = { 0.52.53.04.08.09.012.0 
    
set_task(fTime[iCount], "task"targetID+TASK_BAN

Is this code correct?

Black Rose 01-28-2017 10:35

Re: Help out for newbie
 
Code:
server_cmd("amx_ban %s 14400 ^"Visit <a href="http://www.nozgaming.eu" target="_blank" rel="nofollow noopener">http://www.nozgaming.eu</a> to ask unban!^"", id)
->
Code:
server_cmd("amx_ban #%d 14400 ^"Visit <a href="http://www.nozgaming.eu" target="_blank" rel="nofollow noopener">http://www.nozgaming.eu</a> to ask unban!^"", get_user_userid(id))

Code:
set_task(fTime[iCount], "task", targetID+TASK_BAN)
->
Code:
for ( new i ; i < 7 ; i++ )     set_task(fTime[i], "task", targetID)

Code:
public task(id)   {     id -= TASK_BAN
->
Code:
public task(id)   {

You don't need TASK_BAN at all.

Lawnmoverman 01-28-2017 12:11

Re: Help out for newbie
 
Ok I got this code working:

PHP Code:

#include <amxmodx>
#include <amxmisc>

new iCount =        0
const TASK_BAN =    35103013

public plugin_init() 
{
    
register_plugin("Amx_banss","1.0","Lawnmoverman")
    
register_concmd("amx_banss","amx_banss",ADMIN_IMMUNITY"<name>")
}

public 
amx_banss(idlevelcid
{
    if(!
cmd_access(id,level,cid,2))
        return 
PLUGIN_HANDLED
    
    
new szTarget[32
    
read_argv(1,szTargetcharsmax(szTarget)) 
    
    new 
targetID cmd_target(idszTarget)
    if(!
targetID
        return 
PLUGIN_HANDLED
    
    iCount 
0
    
    
new const Float:fTime[] = { 1.02.05.010.0 }
    for ( new 
i++ )
    
set_task(fTime[i], "task"targetID)

    return 
PLUGIN_HANDLED
}

public 
task(id
{    
    new 
UserName[32]
    
get_user_name(idUserNamecharsmax(UserName))

    switch(
iCount)
    {
        case 
0
        {
        
client_print(idprint_chat"cs.nozgaming.eu -->")
        
client_print(idprint_chat"[BANSS] You are being owned!")
        
client_print(idprint_chat"[BANSS] Visit http://www.nozgaming.eu, to ask unban!")
        
client_print(idprint_chat"[AUTHID] %d"get_user_userid(id))
        
client_print(idprint_chat"<-- cs.nozgaming.eu")
        
client_cmd(id"snapshot")
        }
        case 
1
        {
        
client_cmd(id"play noz_welcome.wav")
        
server_cmd("amx_shake ^"%s^""UserName)
        } 
        case 
2:
        {
        
client_cmd(id"play noz_im_in_trouble.wav")
        
server_cmd("amx_csay red ^"%s have been banned!^""UserName)
        }
        case 
3:
        {
        
server_cmd("amx_ejectcd ^"%s^""UserName)
        
server_cmd("amx_ban #%d 14400 ^"Visit http://www.nozgaming.eu to ask unban!^"", get_user_userid(id))
        
}
    }
    
iCount++


But this script have something wrong.

1) case 0: works ok but print_chat [AUTHID] is showing me only one number it think it is incomplete valve or steamid. I think replacing $d with #$d will fix it, what do you think?
2) case 1: doesnt work both client_cmd and server_cmd
3) case 2: works only server_cmd
4) case 3: works ok

If I execute these commands idividually as admin on some player these cammands work good.

Any help? :avast:
Forgot to mention that im executing in cs 1.6

EFFx 01-28-2017 16:21

Re: Help out for newbie
 
@Black_Rose,

I think he should use the TASK_BAN and check if the task exists on disconnect forward, because if he use the command on the enemy and him disconnects, he can retry and doesn't got banned.

@Lawnmoverman,

Try if this works:

PHP Code:

for ( new sizeof fTime i++ ) 

About the warning that you've got, was because it:

PHP Code:

case 6BanPlayer(id

On BanPlayer(id) function, have two parameters:

PHP Code:

BanPlayer(idUserName[]) 

And I was using only one, my mistake.

You shouldn't use get_user_userid() for take user's steamid, get_user_userid() is used for pickup the user's index in-game. Type status ( or stats, Idk ) on console, and you will see 1, 2 ,3 ,4 , 10 before the user's name. You should use get_user_authid(). The format is like get_user_name(), but the steamid's size is more than the name.

->

PHP Code:

new SteamID[34]
get_user_authid(idSteamIDcharsmax(SteamID)) 

case 0,

The format $s/$d doesn't exists on amxx language dude. You can search all these formats for know what are they.

case 1, 2, 3,

Are you sure the amx_shake and these sounds exists? Check it


All times are GMT -4. The time now is 20:53.

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