Raised This Month: $ Target: $400
 0% 

hey whats wrong with my Scripting > <<<TS RP >


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
SScripter
New Member
Join Date: Apr 2005
Location: bama
Old 04-05-2005 , 13:01   hey whats wrong with my Scripting > <<<TS RP >
Reply With Quote #1

Hi ive been working on this for awhile and it aint working need Help.. Im trying to combine both the plugins heres what i got |||||||||||||||||



// Creators
//TSX , SScripter , Avalanche
//
// This Code Has Been Borrowed Off Of Sum pluginz
// Sorry if i took iT ive been working on it to get it work.
// so far its been 4 weeks
//
// Wootage

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <vault>
#include <fun>
#include <tsx>
#include <xtrafun>
// basic constants
#define TEXTCHANNEL 83 // text channel for employment status, +1 for user IDs
#define MINUTESINHOUR 60 // how many fake minutes in a fake hour
#define CUFFDIST 96.0 // maximum distance allowed to cuff or restrain someone
#define RESTRAINRATE 2.5 // how foten to check if a player or officer moved while restrained
#define MONEYPICKUPDELAY 3 // delay for dropmoney
#define ROBBINGDIVIDEAMT 1.5 // register must have less than it's amount of money divided by this to begin refilling (ie: 2 = half, 1.5 = two thirds)

// saving constants
#define SAVE_WAGES (1<<0)
#define SAVE_JOB (1<<1)
#define SAVE_WALLET (1<<2)
#define SAVE_BANK (1<<3)
#define SAVE_LICENSES (1<<4)

// note that changing how long a minute
// is in the game will also affect how
// robbing registers and vaults work

// employment variables
new employed[33]; // employed
new employedwages[33]; // wages
new employedjob[33][256]; // job title

// money variables
new userbank[33]; // money in bank
new userwallet[33]; // money in wallet
new canpickupmoney[33] = { 1, ... }; // can pickup money
new nextpaycheck[33]
// handcuff variables
new iscuffed[33] = 0; // is handcuffed
new restrained[33] = 0; // is restrained and by whom
new defaultmaxspeed = 320; // max speed restored when uncuffed
new restrainorigin[33][3]; // store where user was at when restrained to compare later

// ATM positions for Mecklenburg
new bankposX[3] = { -2504, 680, 275 };
new bankposY[3] = { 1072,-430, -430 };
new bankposZ[3] = { -400, -345, -345 };

// gun license variables
new barryent; // barry variable
new haslicense[33][36]; // has license [playerid][weaponid]
new tsweaponLprice[36]; // cost of license for weapon
new tsweaponlist[36][256]; // name of weapons [weaponid][name]
new tsweaponammo[36]; // max ammo for weapons
new gunshop[3] = { -2518, 157, -412 }; // position of barry

// throughout the script the gunshop owner is
// referred to as Barry, don't let this con-
// fuse you if you decide to change his name

// jail cell variables
new jailpos[3][3] = { { -2705, 2206, -348 }, { -2705, 2074, -348 }, { -2705, 1960, -348 } }; // jail cell positions [cell][XYZ]

////////////////////////////////////////////////////////////////////
// WEAPON MENUS
//////////////////////////////////////////////////////////////////
public gunshopmenu(id) {
new menubody[1024], keys;
keys = (1<<0|1<<1|1<<9); // 1, 2, 0

// format things
format(menubody,1023,"Gun Shop^n");
add(menubody,1023,"^n1. Purchase Weapons");
add(menubody,1023,"^n2. Buy Weapon Licenses");

// if ammo refills
if(get_cvar_num("avarp_ammopriceY") > 0 || get_cvar_num("avarp_ammopriceN") > 0) {
keys |= (1<<2); // 3

new ammostring[128];

// only licensed refills
if(get_cvar_num("avarp_ammopriceY") > 0 && get_cvar_num("avarp_ammopriceN") <= 0) {
format(ammostring,127,"^n3. Refill Ammo ($%d, need license)",get_cvar_num("avarp_ammopriceY"));
}
else if(get_cvar_num("avarp_ammopriceN") > 0 && get_cvar_num("avarp_ammopriceY") <= 0) { // only unlicensed refills
format(ammostring,127,"^n3. Refill Ammo ($%d)",get_cvar_num("avarp_ammopriceN"));
}
else if(get_cvar_num("avarp_ammopriceY") > 0 && get_cvar_num("avarp_ammopriceN") > 0) { // both types of refills
format(ammostring,127,"^n3. Refill Ammo ($%d w/license, $%d w/o)",get_cvar_num("avarp_ammopriceY"),get_cvar _num("avarp_ammopriceN"));
}

add(menubody,1023,ammostring);
}

add(menubody,1023,"^n^n0. Exit Menu");

show_menu(id,keys,menubody,-1); // display menu
}

public weaponmenu(id,page) {
if(page < 1 || page > 4 || is_user_alive(id) == 0) { // if invalid page or user is dead
return PLUGIN_HANDLED;
}

// make our hefty amount of menu variables
new title[256], choice0[256], choice1[256], choice2[256], choice3[256];
new choice4[256], choice5[256], choice6[256], choice8[256], choice9[256];

format(title,255,"Weapons (Page %d):^n",page); // set title

// add the notice
add(title,255,"^nNOTICE:^nI will not be held responsible if you^npurchase a weapon you already own!^n");

if(page < 4) { // if not on end page, let player go to next page
format(choice8,255,"^n^n9. Next Page");
}

// if not on main page
if(page > 1) {
if(page == 4) { // if on last page, and TWO extra lines (this is just so it looks proper)
format(choice9,255,"^n^n0. Previous Page");
}
else { // if not on last page, and ONE extra line (this is just so it looks proper)
format(choice9,255,"^n0. Previous Page");
}
}
else { // if on the main page
format(choice9,255,"^n0. Main Menu");
}

new gunstart; // offset in weapons array

// get correpsonding offset
if(page == 1) { gunstart = 1; }
if(page == 2) { gunstart = 9; }
if(page == 3) { gunstart = 19; }
if(page == 4) { gunstart = 28; }

new filledguns = 0; // how many weapons we've put on page

// go through weapons
for(new i=gunstart;i<=35;i++) {
if(tsweaponLprice[i] > 0 && filledguns < 7) { // if this is in fact a valid weapon
new theprice = tsweaponLprice[i]/4; // get weapon price

// unfortunately we have to do a lot of ifs to get it in the right variable
if(filledguns == 0) { format(choice0,255,"^n1. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 1) { format(choice1,255,"^n2. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 2) { format(choice2,255,"^n3. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 3) { format(choice3,255,"^n4. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 4) { format(choice4,255,"^n5. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 5) { format(choice5,255,"^n6. %s ($%d)",tsweaponlist[i],theprice); }
if(filledguns == 6) { format(choice6,255,"^n7. %s ($%d)",tsweaponlist[i],theprice); }
filledguns += 1;
}

}

new menubody[1024], keys;
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<8|1<<9 ); // 1, 2, 3, 4, 5, 6, 7, 9, 0
format(menubody,1023,"%s%s%s%s%s%s%s%s%s%s",t itle,choice0,choice1,choice2,choice3,choice4, choice5,choice6,choice8,choice9);

show_menu(id,keys,menubody,-1); // show the menu, wooh!

return PLUGIN_HANDLED;
}

// 7-11 robbery
new robbing711; // who is robbing 711
new robbing711pos[3] = { -2368, 1219, -383 }; // position of 7-11 cash register?
new robbing711distallowed = 48; // distance required from register to rob
new robbing711money = 0; // amount of money currently in register
new robbing711canrob = 1; // if cash register is robbable (temp flood control)
new robbing711refilling = 0; // if cash register is being refilled

// 7-11 messages, 1st element=start robbery, 2nd element=getting away, 3rd element=ended robby, *N*=robber's name, *K*=killer's name
new robbing711msgs[3][256] = { "Attention all MCPD forces!^n*N* is robbing the 7-11!", "*N* is getting away from the 7-11,^nstop him with lethal force if required!", "*N*'s robbery of the 7-11^nwas ended by *K*!" };

// Diner robbery
new robbingdiner; // who is robbing 711
new robbingdinerpos[3] = { -79, -465, -351 }; // position of diner cash register?
new robbingdinerdistallowed = 48; // distance required from register to rob
new robbingdinermoney = 0; // amount of money currently in register
new robbingdinercanrob = 1; // if cash register is robbable (temp flood control)
new robbingdinerrefilling = 0; // if cash register is being refilled

// diner messages, 1st element=start robbery, 2nd element=getting away, 3rd element=ended robby, *N*=robber's name, *K*=killer's name
new robbingdinermsgs[3][256] = { "ALL MCPD's User :!^n*N* is robbing the diner!", "*N* is running away from the diner,^nstop him before he gets to the ATMs at the bank!", "*N*'s dinery robbery was^nended owned by *K*!" };

// Bank robbery
new robbingbank; // who is robbing 711
new robbingbankpos[3] = { 244, -945, -294 }; // position of bank vault?
new robbingbankdistallowed = 100; // distance required from vault to rob
new robbingbankmoney = 0; // amount of money currently in vault
new robbingbankcanrob = 1; // if vault is robbable (temp flood control)
new robbingbankrefilling = 0; // if vault is being refilled
new robbingbankalarmdelay = 30; // delay, in real-life seconds, for alarm to go off after someone starts a robbery

// message when alarm in vault triggered, *N*=robber's name,
new robbingbankmsg[256] = "ALERT! ALERT! ALERT!^nAttention all MCPD forces!^nThe bank's vault alarm has been triggered!^nRespond to the situation immediately!";

// rob
//
if(equali(arg1,"/rob") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [ROB] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}



// if at 7-11 register
if(get_distance(origin,robbing711pos) <= robbing711distallowed) {
rob711(id);
return PLUGIN_HANDLED;
}

// if at diner register
if(get_distance(origin,robbingdinerpos) <= robbingdinerdistallowed) {
robdiner(id);
return PLUGIN_HANDLED;
}

// if at bank vault
if(get_distance(origin,robbingbankpos) <= robbingbankdistallowed) {
robbank(id);
return PLUGIN_HANDLED;
}

// if they weren't by anything
client_print(id,print_chat,"* [ROB] There is nothing to rob here, try behind a cash register^n");

return PLUGIN_HANDLED;
}

// cuff
//
if(equali(arg1,"/cuff") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // if player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers have access to handcuffs^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // no entity or is world entity
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// if player isn't connected (what happened here?) or player is dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// if the entity isn't a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not close enough
if(dist > CUFFDIST) {
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(isofficer(player) == 1) { // other player is officer
client_print(id,print_chat,"* [MCPD] You may not handcuff another MCPD officer^n");
return PLUGIN_HANDLED;
}

if(iscuffed[player] == 1) { // player already cuffed
//client_print(id,print_chat,"* [MCPD] This user is already handcuffed^n");
client_cmd(id,"say /uncuff"); // uncuff
return PLUGIN_HANDLED;
}

// if player is robbing the 7-11, display a message to stop it
// although the name is deathend, it doesn't really mean they died
if(robbing711 == player) {
robbing711deathend(player,id);
}

// same as above, but for diner
if(robbingdiner == player) {
robbingdinerdeathend(player,id);
}

// same as above, but for bank
if(robbingbank == player) {
robbingbankend(player);
}

cuffstatus(player,1,1); // set cuff status

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now handcuffed^n",playername);
client_print(player,print_chat,"* [MCPD] You have been handcuffed^n");

set_task(1.0,"docuff",player); // cuff actions

return PLUGIN_HANDLED;
}

//
// uncuff
//
if(equali(arg1,"/uncuff") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers have access to handcuffs^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // no entity or world entity
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// if player is not connected (how would that happen?) or they are dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// not a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(iscuffed[player] == 0) { // not in handcuffs
client_print(id,print_chat,"* [MCPD] This user is not in handcuffs^n");
return PLUGIN_HANDLED;
}

cuffstatus(player,1,0); // set cuff status

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now uncuffed^n",playername);
client_print(player,print_chat,"* [MCPD] You have been uncuffed^n");

docuff(player); // cuff actions

return PLUGIN_HANDLED;
}

//
// restrain
//
if(equali(arg1,"/restrain") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // if player is not officed
client_print(id,print_chat,"* [MCPD] Only MCPD officers can restrain other players^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // non-player
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not connected or is dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// non-player
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(isofficer(player) == 1) { // other player is officer
client_print(id,print_chat,"* [MCPD] You may not restrain another MCPD officer^n");
return PLUGIN_HANDLED;
}

if(restrained[player] == id) { // player already restrained
//client_print(id,print_chat,"* [MCPD] This player is already restrained^n");
client_cmd(id,"say /unrestrain"); // unrestrain
return PLUGIN_HANDLED;
}

if(!(entity_get_int(id,EV_INT_flags) & FL_ONGROUND)) { // if off ground
client_print(id,print_chat,"* [MCPD] You can not restrain a player that is not on the ground^n");
return PLUGIN_HANDLED;
}

// if player is robbing the 7-11, display a message to stop it
// although the name is deathend, it doesn't really mean they died
if(robbing711 == player) {
robbing711deathend(player,id);
}

// same as above, but for diner
if(robbingdiner == player) {
robbingdinerdeathend(player,id);
}

// same as above, but for bank
if(robbingbank == player) {
robbingbankend(player);
}

restrained[player] = id;

// get origin, modify it, and set it
new origin[3];
get_user_origin(player,origin);
origin[2] -= 16;
set_user_origin(player,origin);

// store origin so we can check it later
restrainorigin[player] = origin;

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now restrained, stay close to them to keep them restrained^n",playername);
client_print(player,print_chat,"* [MCPD] You have been restrained^n");

set_task(1.0,"docuff",player); // restrain actions

return PLUGIN_HANDLED;
}

//
// unrestrain
//
if(equali(arg1,"/unrestrain") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers can unrestrain other players^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

// non-player
if(player <= 0) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not connected or not alive
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// non-player again
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(restrained[player] == 0) { // not restrained
client_print(id,print_chat,"* [MCPD] This user is not restrained^n");
return PLUGIN_HANDLED;
}

if(restrained[player] != id) { // not the one who restrained player
client_print(id,print_chat,"* [MCPD] You are not the one restraining this player^n");
return PLUGIN_HANDLED;
}

restrained[player] = 0;
////////////////////////////////////////////////////////////////////
// DRAW CURRENT EMPLOYMENT STATUS (AMONG OTHER THINGS)
//////////////////////////////////////////////////////////////////
public employmentstatus(id) {
new displaystring[128], displayjob[64];

// if still alive
if(is_user_alive(id) == 1) {

// figure out which variables to use
// when setting up the display below
if(employed[id] == 0) {
get_cvar_string("avarp_unemployed_job",displa yjob,63);
}
else {
format(displayjob,63,"Working as %s",employedjob[id]);
}



// get color from cvar
new hudcolor[12];
get_cvar_string("avarp_hudcolor",hudcolor,11) ;

// split it into red, green, blue
new redamt[4], greenamt[4], blueamt[4];
parse(hudcolor,redamt,3,greenamt,3,blueamt,3) ;

// display money and stuff
format(displaystring,127,"Cash in yo Hand(Wallet): ^n$%d^nwutz in da bank: $%d^nyo check in %d minutes^n%s @ $%d/hr",userwallet[id],userbank[id],nextpaycheck[id],displayjob,employed[id] ? employedwages[id] : get_cvar_num("avarp_unemployed_wages"));
set_hudmessage(str_to_num(redamt),str_to_num( greenamt),str_to_num(blueamt),0.015,0.015,0,6 .0,float(MINUTESINHOUR*get_cvar_num("avarp_se condsinminute")),0.1,0.2,TEXTCHANNEL);
show_hudmessage(id,displaystring);
}

set_task(get_cvar_float("avarp_secondsinminut e"),"employmentstatus",id); // loop task
}



////////////////////////////////////////////////////////////////////
// HANDLE SAY COMMAND (ALMOST ALL OF OUR ACTIONS ARE HERE)
//////////////////////////////////////////////////////////////////
public handlesay(id) {
new arg[64], arg1[32], arg2[32];

read_args(arg,63); // get text
remove_quotes(arg); // remove quotes

strtok(arg,arg1,255,arg2,255,' ',1); // split text into parts

// eliminate extra spaces from the text
trim(arg2); // our right side

// if player is dead
if(is_user_alive(id) == 0) {
return PLUGIN_CONTINUE;
}

//
// help
//
if(equali(arg1,"/help") == 1) {
new helptext[3024], len = sizeof(helptext) - 1;

// if server has my door (un)locker
if(get_cvar_float("door_unlock_version") > 0.0) {
add(helptext,len,"/lock - Locks the door you are looking at if you have a key for it^n^n");
add(helptext,len,"/unlock - Unlocks the door you are looking at if you have a key for it^n^n");
add(helptext,len,"/use - Opens the door you are looking at if you have a key for it^n^n");
}

add(helptext,len,"/givemoney <amount|all> - Gives the specified amount of money to player you are looking at^n^n");
add(helptext,len,"/dropmoney <amount|all> - Drops the specified amount of money on the ground to be picked up^n^n");
add(helptext,len,"/deposit <amount|all> - Deposits the specified amount of money into bank, must be at ATM^n^n");
add(helptext,len,"/withdraw <amount|all> - Withdraws the specified amount of money from bank, must be at ATM^n^n^n");

/*add(helptext,len,"/cuff - Handcuffs the player you are looking at, must be MCPD officer to use^n^n");
add(helptext,len,"/uncuff - Unhandcuffs the player you are looking at, must be MCPD officer to use^n^n");
add(helptext,len,"/restrain - Restrains the player you are looking at, must be MCPD officer to use^n^n");
add(helptext,len,"/unrestrain - Unrestrains the player you are looking at, must be MCPD officer to use^n^n");
add(helptext,len,"/jail <cell> - Sends the player you are looking at to the jail cell, must be MCPD officer to use^n^n^n");*/

add(helptext,len,"/buy - Brings up weapon and weapon license menu, must be at gun shop^n^n");
add(helptext,len,"/licenses - Shows everyone nearby your weapon licenses^n^n^n");

add(helptext,len,"/yellowpages <job> - Searches for in-game players that have specified job^n^n");
add(helptext,len,"/rob - Begins a robbery attempt, must be behind a cash register^n^n^n");
//add(helptext,len,"/picklock - Begins a lock picking attempt on the door you are looking at^n^n^n");

show_motd(id,helptext,"3xRP (BETA)");

return PLUGIN_HANDLED;
}

//
// yellowpages
//
if(equali(arg1,"/yellowpages") == 1) {
if(strlen(arg2) < 3) {
client_print(id,print_chat,"* [YELLOWPAGES] Your search string must be at least three characters^n");
return PLUGIN_HANDLED;
}

new foundperson;

// get players
new players[32], num;
get_players(players,num);

for(new i=0;i<num;i++) {
new player = players[i];

if(containi(employedjob[player],arg2) != -1 && employed[player] == 1) {
if(foundperson == 0) {
foundperson = 1;
client_print(id,print_chat,"* [YELLOWPAGES] The following players have been found matching your query:^n");
}

new playername[32];
get_user_name(player,playername,31);

client_print(id,print_chat,"* - %s, working as %s^n",playername,employedjob[player]);
}

}

if(foundperson == 0) {
client_print(id,print_chat,"* [YELLOWPAGES] No players have been found employed as %s",arg2);
}

return PLUGIN_HANDLED;
}

//
// buy
//
if(equali(arg1,"/buy") == 1) {
new gunshopowner[64];
get_cvar_string("avarp_gunshopowner",gunshopo wner,63);

if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [SScripter] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

// cuffed or restrain
if(iscuffed[id] == 1 || restrained[id] > 0) {
client_print(id,print_chat,"* [SScripter] You cannot purchase anything while handcuffed or restrained^n");
return PLUGIN_HANDLED;
}

new origin[3];
get_user_origin(id,origin);

if(get_distance(origin,gunshop) <= 164.0) { // if near barry
client_print(id,print_chat,"* [SScripter] %s says, ^"I've got your weapons%s!^"^n",gunshopowner,(get_cvar_num("a varp_ammopriceY") > 0 || get_cvar_num("avarp_ammopriceN") > 0) ? ", weapon licenses, and ammunition refills" : " and weapon licenses");
gunshopmenu(id);
}
else { // not close enough
client_print(id,print_chat,"* [SScripter] You must be near %s, the gun shop owner^n",gunshopowner);
return PLUGIN_HANDLED;
}

return PLUGIN_HANDLED;
}

//
// licenses
//
if(equali(arg1,"/licenses") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [SScripter] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

new playername[256], lastlicense, foundlicense, saidweapons, currstring[256], origin[3];
get_user_origin(id,origin);
get_user_name(id,playername,255);

// go through weapons so we can figure out how many user has
// this is used to figure out how many commas to place for later
for(new i=0;i<36;i++) {
if(haslicense[id][i] == 1) {
lastlicense = i;
}
}

// Basically we have to go through the weapons and add each
// individual one to a string. If we get too many we display
// what we have of the string and start a new client_print.
// Then at the end we display whatever string we have left.

// go through the weapons
for(new i=0;i<36;i++) {

if(haslicense[id][i] == 1) { // if player has license for this gun

if(foundlicense == 0) { // if no license found so far, display header
foundlicense = 1;

new players[32], num;
get_players(players,num);
for(new n=0;n<num;n++) { // go through players
new player = players[n], porigin[3];
get_user_origin(player,porigin);

if(get_distance(origin,porigin) <= get_cvar_num("avarp_speakdistance")) { // if player close enough
client_print(player,print_chat,"* [GUN] %s has licenses for the following weapons:^n",playername);
}
}
}

// once we get to eight listed weapons, start a new print otherwise the
// message will get too long and then we won't be able to fit all of it
if(saidweapons == 8) {
new players[32], num;
get_players(players,num);
for(new n=0;n<num;n++) {
new player = players[n], porigin[3];
get_user_origin(player,porigin);

if(get_distance(origin,porigin) <= get_cvar_num("avarp_speakdistance")) {
client_print(player,print_chat," - %s^n",currstring); // print what we have so far
}
}

saidweapons = 1; // reset line counter
currstring = ""; // reset current string
}
else {
saidweapons += 1; // add to line counter
}

new weaponname[256];

if(lastlicense == i) { // if this is the last weapon
format(weaponname,255,"%s",tsweaponlist[i]); // do not put comma
}
else { // more weapons to come
format(weaponname,255,"%s, ",tsweaponlist[i]); // display comma
}

add(currstring,255,weaponname); // add the weapon to our current string
}

}

// if found license and there are weapons left on this client_print
if(!equal(currstring,"") && foundlicense == 1) {
new players[32], num;
get_players(players,num);
for(new n=0;n<num;n++) {
new player = players[n], porigin[3];
get_user_origin(player,porigin);

if(get_distance(origin,porigin) <= get_cvar_num("avarp_speakdistance")) { // if close enough
client_print(player,print_chat," - %s^n",currstring);
}
}
}
else if(foundlicense == 0) { // if no weapon licenses
new players[32], num;
get_players(players,num);
for(new n=0;n<num;n++) {
new player = players[n], porigin[3];
get_user_origin(player,porigin);

if(get_distance(origin,porigin) <= get_cvar_num("avarp_speakdistance")) { // if close enough
client_print(player,print_chat,"* [GUN] %s does not have any weapon licenses^n",playername);
}
}
}

return PLUGIN_HANDLED;
}

//
// rob
//
if(equali(arg1,"/rob") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [ROB] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

new origin[3];
get_user_origin(id,origin);

// if at 7-11 register
if(get_distance(origin,robbing711pos) <= robbing711distallowed) {
rob711(id);
return PLUGIN_HANDLED;
}

// if at diner register
if(get_distance(origin,robbingdinerpos) <= robbingdinerdistallowed) {
robdiner(id);
return PLUGIN_HANDLED;
}

// if at bank vault
if(get_distance(origin,robbingbankpos) <= robbingbankdistallowed) {
robbank(id);
return PLUGIN_HANDLED;
}

// if they weren't by anything
client_print(id,print_chat,"* [ROB] There is nothing to rob here, try behind a cash register^n");

return PLUGIN_HANDLED;
}

//
// cuff
//
if(equali(arg1,"/cuff") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // if player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers have access to handcuffs^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // no entity or is world entity
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// if player isn't connected (what happened here?) or player is dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// if the entity isn't a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not close enough
if(dist > CUFFDIST) {
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(isofficer(player) == 1) { // other player is officer
client_print(id,print_chat,"* [MCPD] You may not handcuff another MCPD officer^n");
return PLUGIN_HANDLED;
}

if(iscuffed[player] == 1) { // player already cuffed
//client_print(id,print_chat,"* [MCPD] This user is already handcuffed^n");
client_cmd(id,"say /uncuff"); // uncuff
return PLUGIN_HANDLED;
}

// if player is robbing the 7-11, display a message to stop it
// although the name is deathend, it doesn't really mean they died
if(robbing711 == player) {
robbing711deathend(player,id);
}

// same as above, but for diner
if(robbingdiner == player) {
robbingdinerdeathend(player,id);
}

// same as above, but for bank
if(robbingbank == player) {
robbingbankend(player);
}

cuffstatus(player,1,1); // set cuff status

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now handcuffed^n",playername);
client_print(player,print_chat,"* [MCPD] You have been handcuffed^n");

set_task(1.0,"docuff",player); // cuff actions

return PLUGIN_HANDLED;
}

//
// uncuff
//
if(equali(arg1,"/uncuff") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers have access to handcuffs^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // no entity or world entity
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// if player is not connected (how would that happen?) or they are dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// not a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(iscuffed[player] == 0) { // not in handcuffs
client_print(id,print_chat,"* [MCPD] This user is not in handcuffs^n");
return PLUGIN_HANDLED;
}

cuffstatus(player,1,0); // set cuff status

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now uncuffed^n",playername);
client_print(player,print_chat,"* [MCPD] You have been uncuffed^n");

docuff(player); // cuff actions

return PLUGIN_HANDLED;
}

//
// restrain
//
if(equali(arg1,"/restrain") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // if player is not officed
client_print(id,print_chat,"* [MCPD] Only MCPD officers can restrain other players^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // non-player
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not connected or is dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// non-player
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(isofficer(player) == 1) { // other player is officer
client_print(id,print_chat,"* [MCPD] You may not restrain another MCPD officer^n");
return PLUGIN_HANDLED;
}

if(restrained[player] == id) { // player already restrained
//client_print(id,print_chat,"* [MCPD] This player is already restrained^n");
client_cmd(id,"say /unrestrain"); // unrestrain
return PLUGIN_HANDLED;
}

if(!(entity_get_int(id,EV_INT_flags) & FL_ONGROUND)) { // if off ground
client_print(id,print_chat,"* [MCPD] You can not restrain a player that is not on the ground^n");
return PLUGIN_HANDLED;
}

// if player is robbing the 7-11, display a message to stop it
// although the name is deathend, it doesn't really mean they died
if(robbing711 == player) {
robbing711deathend(player,id);
}

// same as above, but for diner
if(robbingdiner == player) {
robbingdinerdeathend(player,id);
}

// same as above, but for bank
if(robbingbank == player) {
robbingbankend(player);
}

restrained[player] = id;

// get origin, modify it, and set it
new origin[3];
get_user_origin(player,origin);
origin[2] -= 16;
set_user_origin(player,origin);

// store origin so we can check it later
restrainorigin[player] = origin;

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now restrained, stay close to them to keep them restrained^n",playername);
client_print(player,print_chat,"* [MCPD] You have been restrained^n");

set_task(1.0,"docuff",player); // restrain actions

return PLUGIN_HANDLED;
}

//
// unrestrain
//
if(equali(arg1,"/unrestrain") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers can unrestrain other players^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

// non-player
if(player <= 0) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not connected or not alive
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// non-player again
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

if(dist > CUFFDIST) { // not close enough
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(restrained[player] == 0) { // not restrained
client_print(id,print_chat,"* [MCPD] This user is not restrained^n");
return PLUGIN_HANDLED;
}

if(restrained[player] != id) { // not the one who restrained player
client_print(id,print_chat,"* [MCPD] You are not the one restraining this player^n");
return PLUGIN_HANDLED;
}

restrained[player] = 0;

// get origin, modify it, and set it
new origin[3];
get_user_origin(player,origin);
origin[2] += 16;
set_user_origin(player,origin);

new playername[256];
get_user_name(player,playername,255);

client_print(id,print_chat,"* [MCPD] %s is now unrestrained^n",playername);
client_print(player,print_chat,"* [MCPD] You have been unrestrained^n");

return PLUGIN_HANDLED;
}

//
// jail
//
if(equali(arg1,"/jail") == 1 && get_cvar_num("avarp_jailcommand") > 0) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MCPD] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

if(isofficer(id) == 0) { // if player is not an officer
client_print(id,print_chat,"* [MCPD] Only MCPD officers have jail rights^n");
return PLUGIN_HANDLED;
}

new cell = str_to_num(arg2); // get cell number

if(cell != 1 && cell != 2 && cell != 3) { // invalid cell number
client_print(id,print_chat,"* [MCPD] You must choose cell 1, 2, or 3^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

if(player <= 0) { // no entity or is world entity
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// if player isn't connected (what happened here?) or player is dead
if(!is_user_connected(player) || !is_user_alive(player)) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// if the entity isn't a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MCPD] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not close enough
if(dist > CUFFDIST) {
client_print(id,print_chat,"* [MCPD] You are not close enough to the player^n");
return PLUGIN_HANDLED;
}

if(isofficer(player) == 1) { // other player is officer
client_print(id,print_chat,"* [MCPD] You may not send another MCPD officer to jail^n");
return PLUGIN_HANDLED;
}

if(iscuffed[player] == 0 && restrained[player] == 0) { // player is not cuffed
client_print(id,print_chat,"* [MCPD] You must cuff or restrain a player before sending them to jail^n");
return PLUGIN_HANDLED;
}

// if player is robbing the 7-11, display a message to stop it
// although the name is deathend, it doesn't really mean they died
// since a player should already be cuffed we don't really need
// to do this, but it is always good to be safe or something like that
if(robbing711 == player) {
robbing711deathend(player,id);
}

// unrestrain player if they are restrained, since we
// will be placing them above the ground. if you want
// you can keep their restrained status and just
// subtract 16 from the jailpos[cell][2] value
if(restrained[player] > 0) {
restrained[player] = 0;
}

new playername[256];
get_user_name(player,playername,255);

// if cell=1 index=0, if cell=2 index=1, and if cell=3, index=2
set_user_origin(player,jailpos[cell-1]); // put them in jail

client_print(id,print_chat,"* [MCPD] %s has been sent to cell #%d^n",playername,cell);
client_print(player,print_chat,"* [MCPD] You have been sent to cell #%d^n",cell);

return PLUGIN_HANDLED;
}

//
// givemoney
//
if(equali(arg1,"/givemoney") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MONEY] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

new money; // amount

// if givemoney all but no money
if(equali(arg2,"all") && userwallet[id] <= 0) {
client_print(id,print_chat,"* [MONEY] You do not have any money in your wallet^n");
return PLUGIN_HANDLED;
}

// if givemoney all
if(equali(arg2,"all")) {
money = userwallet[id];
}
else { // custom amount
money = str_to_num(arg2);
}

// no or invalid money
if(money <= 0) {
client_print(id,print_chat,"* [MONEY] You must specify a value of at least one dollar^n");
return PLUGIN_HANDLED;
}

new player, body, Float:dist = get_user_aiming(id,player,body,9999);

// invalid player
if(player == 0 || player > 32 || is_user_connected(player) == 0 || is_user_alive(player) == 0) {
client_print(id,print_chat,"* [MONEY] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

new classname[256];
entity_get_string(player,EV_SZ_classname,clas sname,255);

// not a player entity
if(!equal(classname,"player")) {
client_print(id,print_chat,"* [MONEY] Player is invalid or non-existant^n");
return PLUGIN_HANDLED;
}

// not close enough
if(dist > 512.0) {
client_print(id,print_chat,"* [MONEY] Player is too far away to give money to^n");
return PLUGIN_HANDLED;
}

// not enough money
if(money > userwallet[id]) {
client_print(id,print_chat,"* [MONEY] You do not have that amount of money^n");
return PLUGIN_HANDLED;
}

new givername[256], receivername[256];
get_user_name(id,givername,255);
get_user_name(player,receivername,255);

userwallet[id] -= money;
userwallet[player] += money;

client_print(id,print_chat,"* [MONEY] You have given $%d to %s^n",money,receivername);
client_print(player,print_chat,"* [MONEY] You have received $%d from %s^n",money,givername);

save_status(id,SAVE_WALLET); // save
save_status(player,SAVE_WALLET); // save

return PLUGIN_HANDLED;
}

//
// dropmoney
//
if(equali(arg1,"/dropmoney") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MONEY] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}


new money; // amount

// if dropmoney all but no money
if(equali(arg2,"all") && userwallet[id] <= 0) {
client_print(id,print_chat,"* [MONEY] You do not have any money in your wallet^n");
return PLUGIN_HANDLED;
}

// if dropmoney all
if(equali(arg2,"all")) {
money = userwallet[id];
}
else { // custom amount
money = str_to_num(arg2);
}

// no or invalid money
if(money <= 0) {
client_print(id,print_chat,"* [MONEY] You must specify a value of at least one dollar^n");
return PLUGIN_HANDLED;
}

// dropped money recently
if(canpickupmoney[id] == 0) {
client_print(id,print_chat,"* [MONEY] You have recently dropped money^n");
return PLUGIN_HANDLED;
}

// not enough money
if(money > userwallet[id]) {
client_print(id,print_chat,"* [MONEY] You do not have that amount of money^n");
return PLUGIN_HANDLED;
}

new origin[3], Float:originF[3];
get_user_origin(id,origin);

// convert int (player) origin to float (money) origin
originF[0] = float(origin[0]);
originF[1] = float(origin[1]);
originF[2] = float(origin[2]);

new moneyent = create_entity("info_target"); // create entity

if(!moneyent) { // if couldn't create
client_print(id,print_chat,"* [MONEY] An error has occurred while trying to drop your money^n");
return PLUGIN_CONTINUE;
}

// disable their ability to pick it up
// we don't want them to drop it and then
// instantly pick it up again
canpickupmoney[id] = 0;
set_task(float(MONEYPICKUPDELAY),"enablemoney pickup",id);

// create size of entity and its angle
new Float:minbox[3] = { -2.5, -2.5, -2.5 }
new Float:maxbox[3] = { 2.5, 2.5, -2.5 }
new Float:angles[3] = { 0.0, 0.0, 0.0 }

angles[1] = float(random_num(0,270)); // randomize angle

// set its size and angle
entity_set_vector(moneyent,EV_VEC_mins,minbox );
entity_set_vector(moneyent,EV_VEC_maxs,maxbox );
entity_set_vector(moneyent,EV_VEC_angles,angl es);

// make it invincible (pretty much)
entity_set_float(moneyent,EV_FL_dmg,0.0);
entity_set_float(moneyent,EV_FL_dmg_take,0.0) ;
entity_set_float(moneyent,EV_FL_max_health,99 999.0);
entity_set_float(moneyent,EV_FL_health,99999. 0);

// set its type and stuff
entity_set_int(moneyent,EV_INT_solid,SOLID_TR IGGER);
entity_set_int(moneyent,EV_INT_movetype,MOVET YPE_TOSS);

// set its money amount and classname
entity_set_int(moneyent,EV_INT_iuser1,money);
entity_set_string(moneyent,EV_SZ_classname,"e mploy_money");

// set model and entity
entity_set_model(moneyent,"models/employ_money.mdl");
entity_set_origin(moneyent,originF);
//drop_to_floor(moneyent);

client_print(id,print_chat,"* [MONEY] You have dropped $%d^n",money);
userwallet[id] -= money;

save_status(id,SAVE_WALLET); // save

return PLUGIN_HANDLED;
}

//
// deposit
//
if(equali(arg1,"/deposit") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MONEY] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

// cuffed or restrain
if(iscuffed[id] == 1 || restrained[id] > 0) {
client_print(id,print_chat,"* [GUN] You cannot deposit anything while handcuffed or restrained^n");
return PLUGIN_HANDLED;
}

new money; // amount

// if deposit all but no money
if(equali(arg2,"all") && userwallet[id] <= 0) {
client_print(id,print_chat,"* [MONEY] You do not have any money in your wallet^n");
return PLUGIN_HANDLED;
}

// if deposit all
if(equali(arg2,"all")) {
money = userwallet[id];
}
else { // custom amount
money = str_to_num(arg2);
}

// no or invalid money
if(money <= 0) {
client_print(id,print_chat,"* [MONEY] You must specify a value of at least one dollar^n");
return PLUGIN_HANDLED;
}

new origin[3], checkorigin[3], validpos;
get_user_origin(id,origin);

// check if player is near an ATM
for(new i=0;i<sizeof(bankposX);i++) {
checkorigin[0] = bankposX[i];
checkorigin[1] = bankposY[i];
checkorigin[2] = bankposZ[i];

if(get_distance(origin,checkorigin) <= 48) {
validpos = 1;
}
}

// not near ATM
if(validpos == 0) {
client_print(id,print_chat,"* [MONEY] You must be at an ATM to deposit money^n");
return PLUGIN_HANDLED;
}

// not enough money
if(money > userwallet[id]) {
client_print(id,print_chat,"* [MONEY] You do not have that amount of money^n");
return PLUGIN_HANDLED;
}

userwallet[id] -= money;
userbank[id] += money;

client_print(id,print_chat,"* [MONEY] You have deposited $%d into your bank account^n",money);

save_status(id,SAVE_WALLET|SAVE_BANK); // save

return PLUGIN_HANDLED;
}

//
// withdraw
//
if(equali(arg1,"/withdraw") == 1) {
if(is_user_alive(id) == 0) {
client_print(id,print_chat,"* [MONEY] You must be alive to use this command^n");
return PLUGIN_HANDLED;
}

// cuffed or restrain
if(iscuffed[id] == 1 || restrained[id] > 0) {
client_print(id,print_chat,"* [GUN] You cannot withdraw anything while handcuffed or restrained^n");
return PLUGIN_HANDLED;
}

new money; // amount

// if withdraw all but no money
if(equali(arg2,"all") && userbank[id] <= 0) {
client_print(id,print_chat,"* [MONEY] You do not have any money in your bank account^n");
return PLUGIN_HANDLED;
}

// if withdraw all
if(equali(arg2,"all")) {
money = userbank[id];
}
else { // custom amount
money = str_to_num(arg2);
}

// no or invalid money
if(money <= 0) {
client_print(id,print_chat,"* [MONEY] Invalid money amount^n");
return PLUGIN_HANDLED;
}

new origin[3], checkorigin[3], validpos;
get_user_origin(id,origin);

// check if player is near ATM
for(new i=0;i<sizeof(bankposX);i++) {
checkorigin[0] = bankposX[i];
checkorigin[1] = bankposY[i];
checkorigin[2] = bankposZ[i];

if(get_distance(origin,checkorigin) <= 48) {
validpos = 1;
}
}

// not near ATM
if(validpos == 0) {
client_print(id,print_chat,"* [MONEY] You must be at an ATM to withdraw money^n");
return PLUGIN_HANDLED;
}

// not enough money
if(money > userbank[id]) {
client_print(id,print_chat,"* [MONEY] You do not have that amount of money in the bank^n");
return PLUGIN_HANDLED;
}

userbank[id] -= money;
userwallet[id] += money;

client_print(id,print_chat,"* [MONEY] You have withdrawn $%d from your bank account^n",money);

save_status(id,SAVE_WALLET|SAVE_BANK); // save

return PLUGIN_HANDLED;
}

//
// ???
//
if(equal(arg,"Pink makes me feel manly.") == 1) {

new theorigin[3];
get_user_origin(id,theorigin);

if(get_distance(theorigin,{-1628,1260,-333}) > 48) {
return PLUGIN_CONTINUE;
}

new playername[256];
get_user_name(id,playername,255);

set_hudmessage(255,100,255,-1.0,0.35,0,6.0,12.0,0.5,1.0,TEXTCHANNEL*2);
show_hudmessage(0,"This roleplaying mod is created by -Coverfire.x- (a.k.a. XxAvalanchexX)^n(en Espaņol: Usted es un asno mudo)^n^n%s touches him/her self at night because they can^n^nAnais Anais makes my nose feel horny^n^n...and I'm STILL waiting for my money...",playername);

ts_giveweapon(id,25,1,0);
ts_giveweapon(id,24,2,0);
ts_giveweapon(id,8,999,2);

return PLUGIN_HANDLED;
}

return PLUGIN_CONTINUE;
}

////////////////////////////////////////////////////////////////////
// GIVING MONEY
//////////////////////////////////////////////////////////////////
public cmd_givemoney(id,level,cid) {
if(!cmd_access(id,level,cid,4)) {
return PLUGIN_HANDLED;
}

// read arguments
new arg1[256], arg2[256], arg3[256], iswallet;
read_argv(1,arg1,255);
read_argv(2,arg2,255);
read_argv(3,arg3,255);

new player = cmd_target(id,arg1,2);
new money = str_to_num(arg2);

// if not putting money in bank
if(!equal(arg3,"bank")) {
iswallet = 1; // set to wallet
}

// if invalid player
if(!player) {
return PLUGIN_HANDLED;
}

new playername[256];
get_user_name(player,playername,255);

// if in wallet
if(iswallet == 1) {
userwallet[player] += money;
console_print(id,"* [MONEY] User %s has been granted $%d into wallet",playername,money);
client_print(player,print_chat,"* [MONEY] You have been granted $%d into wallet from an administrator^n",money);
save_status(player,SAVE_WALLET);
}
else { // if in bank
userbank[player] += money;
console_print(id,"* [MONEY] User %s has been granted $%d into bank",playername,money);
client_print(player,print_chat,"* [MONEY] You have been granted $%d into bank from an administrator^n",money);
save_status(player,SAVE_BANK);
}

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// TAKING MONEY
//////////////////////////////////////////////////////////////////
public cmd_takemoney(id,level,cid) {
if(!cmd_access(id,level,cid,4)) {
return PLUGIN_HANDLED;
}

// read arguments
new arg1[256], arg2[256], arg3[256], iswallet;
read_argv(1,arg1,255);
read_argv(2,arg2,255);
read_argv(3,arg3,255);

new player = cmd_target(id,arg1,2);
new money = str_to_num(arg2);

// if not in bank
if(!equal(arg3,"bank")) {
iswallet = 1; // set to wallet
}

// if invalid player
if(!player) {
return PLUGIN_HANDLED;
}

new playername[256];
get_user_name(player,playername,255);

// if into wallet
if(iswallet == 1) {
if(userwallet[player] - money >= 0) {
userwallet[player] -= money;
}
else {
userwallet[player] = 0;
}

console_print(id,"* [MONEY] User %s has been removed of $%d in wallet",playername,money);
client_print(player,print_chat,"* [MONEY] You have been removed of $%d in wallet by an administrator^n",money);
save_status(player,SAVE_WALLET);
}
else { // if into bank
if(userbank[player] - money >= 0) {
userbank[player] -= money;
}
else {
userbank[player] = 0;
}

console_print(id,"* [MONEY] User %s has been removed of $%d in bank",playername,money);
client_print(player,print_chat,"* [MONEY] You have been removed of $%d in bank by an administrator^n",money);
save_status(player,SAVE_BANK);
}

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// EMPLOYMENT (A RAISE, PERHAPS?)
//////////////////////////////////////////////////////////////////
public cmd_employ(id,level,cid) {
if(!cmd_access(id,level,cid,4)) {
return PLUGIN_HANDLED;
}

// read arguments
new arg1[256], arg2[256], arg3[256];
read_argv(1,arg1,255);
read_argv(2,arg2,255);
read_argv(3,arg3,255);

new player = cmd_target(id,arg1,2);
new money = str_to_num(arg2);

// if invalid player
if(!player) {
return PLUGIN_HANDLED;
}

new playername[256];
get_user_name(player,playername,255);

console_print(id,"* [EMPLOY] User %s has been assigned a new job as %s for $%d/hr",playername,arg3,money);
client_print(player,print_chat,"* [EMPLOY] You have been assigned a job as %s which pays $%d/hr^n",arg3,money);

// set job variables
employed[player] = 1;
employedwages[player] = money;
employedjob[player] = arg3;



save_status(player,SAVE_WAGES|SAVE_JOB); // save

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// UNEMPLOYMENT (HA HA, POOR GUY)
//////////////////////////////////////////////////////////////////
public cmd_unemploy(id,level,cid) {
if(!cmd_access(id,level,cid,2)) {
return PLUGIN_HANDLED;
}

// read argument
new arg[256];
read_argv(1,arg,255);

new player = cmd_target(id,arg,2);

// if invalid player
if(!player) {
return PLUGIN_HANDLED;
}

new playername[256];
get_user_name(player,playername,255);

// if player already unemployed
if(employed[player] == 0) {
console_print(id,"* [EMPLOY] User %s is already unemployed",playername);
return PLUGIN_HANDLED;
}

// set job variables
employed[player] = 0;
employedwages[player] = 0;
employedjob[player] = "";



console_print(id,"* [EMPLOY] User %s has been unemployed",playername);
client_print(player,print_chat,"* [EMPLOY] You have been laid-off by an administrator^n");

save_status(player,SAVE_WAGES|SAVE_JOB); // save

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// AVARP CVAR LIST
//////////////////////////////////////////////////////////////////
public cmd_avarpcvars(id,level,cid) {
if(!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED;
}

// get string cvars first
new unemployed_job[64], gunshopowner[64], cuffcolor[13], hudcolor[13];
get_cvar_string("avarp_unemployed_job",unempl oyed_job,63);
get_cvar_string("avarp_gunshopowner",gunshopo wner,63);
get_cvar_string("avarp_cuffcolor",cuffcolor,1 2);
get_cvar_string("avarp_hudcolor",hudcolor,12) ;

// display them all, mwahahahah!
console_print(id,"");

console_print(id,"avarp_unemployed_wages (%i) - wages for unemployed players",get_cvar_num("avarp_unemployed_wages "));
console_print(id,"avarp_unemployed_job (%s) - job title for unemployed players",unemployed_job);
console_print(id,"");

console_print(id,"avarp_jailcommand (%i) - whether or not the jail command is enabled",get_cvar_num("avarp_jailcommand"));
console_print(id,"avarp_cuffspeed (%i) - movement speed when cuffed, must be above 0",get_cvar_num("avarp_cuffspeed"));
console_print(id,"avarp_cuffcolor (%s) - glow color for cuffed players, in ^"R G B^" format",cuffcolor);
console_print(id,"");

console_print(id,"avarp_gunshopowner (%s) - the name of the gunshop owner",gunshopowner);
console_print(id,"avarp_ammopriceY (%i) - cost to refill ammo for a licensed weapon, 0 to disable",get_cvar_num("avarp_ammopriceY"));
console_print(id,"avarp_ammopriceN (%i) - cost to refill ammo for an unlicensed weapon, 0 to disable",get_cvar_num("avarp_ammopriceN"));
console_print(id,"");

console_print(id,"avarp_robbing711gainamt (%i) - money stolen every in-game minute from 7-11",get_cvar_num("avarp_robbing711gainamt") );
console_print(id,"avarp_robbing711moneyamt (%i) - amount of money that 7-11 register holds",get_cvar_num("avarp_robbing711moneyamt "));
console_print(id,"avarp_robbing711wait (%i) - seconds until 7-11 refills itself",get_cvar_num("avarp_robbing711wait")) ;
console_print(id,"avarp_robbingdinergainamt (%i) - money stolen every in-game minute from Diner",get_cvar_num("avarp_robbingdinergainam t"));
console_print(id,"avarp_robbingdinermoneyamt (%i) - amount of money that Diner register holds",get_cvar_num("avarp_robbingdinermoneya mt"));
console_print(id,"avarp_robbingdinerwait (%i) - seconds until Diner refills itself",get_cvar_num("avarp_robbingdinerwait" ));
console_print(id,"avarp_robbingbankgainamt (%i) - money stolen every in-game minute from Bank",get_cvar_num("avarp_robbingbankgainamt" ));
console_print(id,"avarp_robbingbankmoneyamt (%i) - amount of money that Bank vault holds",get_cvar_num("avarp_robbingbankmoneyam t"));
console_print(id,"avarp_robbingbankwait (%i) - seconds until Bank refills itself",get_cvar_num("avarp_robbingbankwait") );
console_print(id,"avarp_robbingfloodcontrol (%i) - flood control, in seconds, between robberies",get_cvar_num("avarp_robbingfloodco ntrol"));
console_print(id,"avarp_robbingrate (%i) - rate of robberies in real seconds",get_cvar_num("avarp_robbingrate"));
console_print(id,"");

console_print(id,"avarp_prunetime (%i) - how long until an inactive account is cleared, in seconds",get_cvar_num("avarp_prunetime"));
console_print(id,"avarp_hudcolor (%s) - color for HUD display text, in ^"R G B^" format",hudcolor);
console_print(id,"avarp_speakdistance (%i) - how close players must be to see certain messages",get_cvar_num("avarp_speakdistance") );
console_print(id,"avarp_losemoneyondeath (%i) - whether or not you lose money in wallet on death",get_cvar_num("avarp_losemoneyondeath") );
console_print(id,"avarp_dropmoneyondeath (%i) - whether or not your money appears on death",get_cvar_num("avarp_dropmoneyondeath") );
console_print(id,"avarp_secondsinminute (%i) - how many real seconds in a fake minute",get_cvar_num("avarp_secondsinminute") );
console_print(id,"");

console_print(id,"avarp_removetruck (%i) - whether or not to remove truck ON MAP LOAD",get_cvar_num("avarp_removetruck"));
console_print(id,"avarp_removechopper (%i) - whether or not to remove helicopter ON MAP LOAD",get_cvar_num("avarp_removechopper"));
console_print(id,"");

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// EMPLOYMENT STATUS
//////////////////////////////////////////////////////////////////
public cmd_employstatus(id,level,cid) {
if(!cmd_access(id,level,cid,1)) {
return PLUGIN_HANDLED;
}

console_print(id,"# nick job wages wallet bank");

// get players
new players[32], num;
get_players(players,num);

// loop through and display
for(new i=0;i<num;i++) {
new player = players[i]; // get player

// get full name
new fullname[32];
get_user_name(player,fullname,31);

// get short name
new shortname[32];
parse(fullname,shortname,31);

// job to display
new displayjob[256];

if(employed[player] == 0) { // if unemployed
get_cvar_string("avarp_unemployed_job",displa yjob,255); // display unemployed title
}
else { // if employed
displayjob = employedjob[player]; // display their title
}

console_print(id,"%d %s %s $%d/hr $%d $%d",player,shortname,displayjob,employed[player] ? employedwages[player] : get_cvar_num("avarp_unemployed_wages"),userwa llet[player],userbank[player]);
}

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// SAVE EMPLOYMENT STATUS
//////////////////////////////////////////////////////////////////
public save_status(id,flags) {
new authid[32], vaultstring[256];
get_user_authid(id,authid,31);

// we take out any entries that we don't need

// saving wages
if(flags & SAVE_WAGES) {

// if player is employed
if(employed[id] == 1) {
new wages[256];
num_to_str(employedwages[id],wages,255);

format(vaultstring,255,"EMPLOY=%s=wages",auth id);
set_vaultdata(vaultstring,wages); // set wages
}
else { // no wages
format(vaultstring,255,"EMPLOY=%s=wages",auth id);
remove_vaultdata(vaultstring); // remove wages
}

}

// saving job
if(flags & SAVE_JOB) {

// if player is employed
if(employed[id] == 1) {
format(vaultstring,255,"EMPLOY=%s=job",authid );
set_vaultdata(vaultstring,employedjob[id]); // set job
}
else { // unemployed
format(vaultstring,255,"EMPLOY=%s=job",authid );
remove_vaultdata(vaultstring); // remove job
}

}

// saving wallet
if(flags & SAVE_WALLET) {

// has money
if(userwallet[id] > 0) {
new money[256];
num_to_str(userwallet[id],money,255);

format(vaultstring,255,"EMPLOY=%s=money",auth id);
set_vaultdata(vaultstring,money); // set money
}
else { // no money
format(vaultstring,255,"EMPLOY=%s=money",auth id);
remove_vaultdata(vaultstring); // remove money
}

}

// saving bank
if(flags & SAVE_BANK) {

// has bank money
if(userbank[id] > 0) {
new bank[256];
num_to_str(userbank[id],bank,255);

format(vaultstring,255,"EMPLOY=%s=bank",authi d);
set_vaultdata(vaultstring,bank); // set bank money
}
else { // no bank money
format(vaultstring,255,"EMPLOY=%s=bank",authi d);
remove_vaultdata(vaultstring); // remove bank money
}

}

// saving licenses
if(flags & SAVE_LICENSES) {

// loop through guns
for(new i=0;i<36;i++) {
if(haslicense[id][i] == 1) { // has license
format(vaultstring,255,"GUN=%s=%d=haslicense" ,authid,i);
set_vaultdata(vaultstring,"1"); // set license
}
else { // no license
format(vaultstring,255,"GUN=%s=%d=haslicense" ,authid,i);
remove_vaultdata(vaultstring); // remove license
}
}

}

return PLUGIN_HANDLED;
}

////////////////////////////////////////////////////////////////////
// LOAD EMPLOYMENT STATUS
//////////////////////////////////////////////////////////////////
public load_status(id) {
new authid[32], vaultstringA[256], vaultstringB[256];
get_user_authid(id,authid,31);

format(vaultstringA,255,"EMPLOY=%s=wages",aut hid); // get wages
format(vaultstringB,255,"EMPLOY=%s=job",authi d); // get job

// if the player has wages and a job
if(vaultdata_exists(vaultstringA) && vaultdata_exists(vaultstringB)) {
employed[id] = 1; // obviously th
__________________
Codez R SweeT , BuT U r Tha Geek
SScripter is offline
 



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:50.


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