AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Rope Mod Help (https://forums.alliedmods.net/showthread.php?t=50502)

jbz0131 01-27-2007 22:42

Rope Mod Help
 
Hi I am currently working on a rope mod for TSRP. I'm very inexperienced at coding so I would really appreciate some help.

I basicaly want this plugin to allow cops on the server type /rope to drag users to jail. I want it so that you type /rope again to unrope them. I would like it so that only cops are allowed to use it, which is where I'm probably having trouble. Here is the code so far:

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

new ropemdl

public plugin_init()
{
        register_plugin("Rope Mod","1.00","Eagle Eye")
        register_concmd("say /rope","rope")
        register_cvar("rp_police_start","1")
        register_cvar("rp_police_end","12")
        register_cvar("rope_speed","850")
}
public plugin_precache()
{
        ropemdl = precache_model("sprites/rope.spr")
}
public rope(id)
{
        new entid, ropebody
        get_user_aiming(id,entid,ropebody,100)
        if(!is_user_connected(entid))
        {
                return PLUGIN_HANDLED
        }
        if(is_user_connected(entid))
        {
                new name[33], name2[33], authid[32], authid2[32], query[256]
                get_user_name(id, name, sizeof(name))
                get_user_name(entid, name2, sizeof(name2))
                get_user_authid(id, authid, 31)
                get_user_authid(entid, authid2, 31)
                format( query, 255, "SELECT JobID FROM money WHERE steamid='%s'", authid)
                result = dbi_query(dbc,"%s",query)
                if( dbi_nextrow( result ) > 0 )
                {
                        if(!is_user_alive(id))
                        {
                                client_print(id, print_chat, "[RopeMod] Access Denied")
                                return PLUGIN_HANDLED
                        }
                        new job[32], JobID
                        dbi_field( result, 1, job, 31)
                        dbi_free_result(result)
                        JobID = str_to_num(job)
                        if((JobID >= mcpdjobs[0] && JobID <= mcpdjobs[1]))
                        {
                                if(roped[entid] == 0)
                                {
                                        format( query, 255, "SELECT JobID FROM money WHERE steamid='%s'", authid2)
                                        result = dbi_query(dbc,"%s",query)
                                        if( dbi_nextrow( result ) > 0 )
                                        {
                                                new job2[32], JobID2
                                                dbi_field( result, 1, job2, 31)
                                                dbi_free_result(result)
                                                JobID2 = str_to_num(job2)
                                                if((JobID2 >= mcpdjobs[0] && JobID2 <= mcpdjobs[1]) || (JobID2 == 1))
                                                {
                                                        client_print(id,print_chat,"[RopeMod] You cannot rope another MCPD officer!^n", name2)
                                                }
                                                else
                                                        drag(entid)
                                                        client_print(entid,print_chat,"[RopeMod] You have been roped!^n",name)
                                                        client_print(id,print_chat,"[RopeMod] You have roped the player!^n",name2)
                                                        return PLUGIN_HANDLED
                                        }
                                }
                                if(roped[entid] == 1)
                                {
                                        remove_rope(entid)
                                        client_print(entid,print_chat,"[RopeMod] You have been unroped!^n",name)
                                        client_print(id,print_chat,"[RopeMod] You have unroped the player!^n",name2)
                                        return PLUGIN_HANDLED
                                }
                        }
                        else
                        {
                                client_print(id,print_chat,"[RopeMod] You have to work for the MCPD to (un)rope someone!^n")
                                return PLUGIN_HANDLED
                        }
                }
        }       
}
public ropebody
{
        roped[id] = 1
        for(new i=1;i<=35;i++)
        {
                client_cmd(id,"weapon_%d; drop",i)
        }
        set_task(0.5,"slowdown",id)
       
        message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        write_coord(idorigin[0])
        write_coord(idorigin[1])
        write_coord(idorigin[2])
        write_coord(targetorigin[0])
        write_coord(targetorigin[1])
        write_coord(targetorigin[2])
        write_short(ropemdl)
        write_byte(1)      // framestart
        write_byte(1)      // framerate
        write_byte(0)      // life in 0.1's
        write_byte(5)      // width
        write_byte(0)      // noise
        write_byte(255)  // red
        write_byte(0)      // green
        write_byte(0)      // blue
        write_byte(200)  // brightness
        write_byte(0)      // speed
        message_end()
}
        return PLUGIN_HANDLED
}
public slowdown(id)
{
        set_user_maxspeed(id,get_user_maxspeed(id)-get_cvar_num("rp_cuffed_speedloose"))
        return PLUGIN_HANDLED
}
public drag(parm[])
{
        // Drags player to you
        new id = parm[0]
        new victim = parm[1]

        if ( !roped[id] )
        {
                retrun PLUGIN_HANDLED
        }
        if ( !is_user_alive(victim) ) {
                remove_rope(id)
                return PLUGIN_HANDLED
        }

        new Float:fl_Velocity[3]
        new idOrigin[3], vicOrigin[3]

        get_user_origin(entid, vicOrigin)
        get_user_origin(id, idOrigin)

        new distance = get_distance(idOrigin, vicOrigin)

        if ( distance > 3 ) {
                new Float:fl_Time = distance / get_cvar_float("rope_speed")

                fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
                fl_Velocity[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
                fl_Velocity[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
        }
        else {
                fl_Velocity[0] = 0.0
                fl_Velocity[1] = 0.0
                fl_Velocity[2] = 0.0
        }

        Entvars_Set_Vector(victim, EV_VEC_velocity, fl_Velocity)
}
public remove_rope(id)
{
        roped[id] = 0

        rope_remove(id)

        remove_task(id)
}
public rope_remove(id)
{
        // Remove the rope
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
        write_byte(99)                //TE_KILLBEAM
        write_short(id)        //entity
        message_end()
}

If you can help me, I'd be really thankful.

SenzuV3 08-05-2007 04:00

Re: Rope Mod Help
 
I'm also interested in something like this. Does anyone know how to get it properly working?

Doc-Holiday 08-05-2007 04:49

Re: Rope Mod Help
 
can you use

if(get_user_team(id) != cops)
return 1;


im not familiar with the game

XmINiX 08-13-2007 14:17

Re: Rope Mod Help
 
Remo Made a cool function like this Just look it up...
it checks the Jobid cvars


All times are GMT -4. The time now is 00:37.

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