AlliedModders

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

wouter 02-27-2006 17:08

Camouflage
 
Hey egain :D
guess what? i was bored egain :P
This one is bigger, and far from ready.
But i dont know or it is right untill now.
The consept is simple: for 16000$ you can buy an enemy suit.
Code:
/* Plugin generated by AMXX-Studio */ // say \camouflage // say_team \camouflage // amxx_camouflage <1/0> #include <amxmodx> #include <fun> #include <cstrike> new PLUGIN[]="Camouflage" new AUTHOR[]="wouter" new VERSION[]="1.00" public plugin_init()     {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_camouflage", "cmd_camouflage", ADMIN_SLAY, "<1/0>") } public cmd_camouflage(id, level, cid)     {     if Player(cs_get_user_money >= 1600)         {               if Player (CS_TEAM_CT)             {             if Player (is_user_alive)                 {                 if(cs_get_user_model(index,model[CS_CT_URBAN], len)                 {                     cs_set_user_model(index, const model[CS_T_TERROR])                 }                 else if (cs_get_user_model(index, model[CS_CT_GSG9], len)                 {                     cs_set_user_model(index, const model[CS_T_LEET])                 }                 else if (cs_get_user_model(index, model[CS_CT_GIGN], len)                 {                     cs_set_user_model(index,const model[CS_T_ARCTIC])                 }                 else if (cs_get_user_model(index,model [CS_CT_SAS], len)                 {                     cs_set_user_model(index, const model [CS_T_GUERILLA])                 }             }             if Player (CS_TEAM_T)                 {                 if Player (is_user_alive)                     {                     if(cs_get_user_model(index,model[CS_T_TERROR], len)                     {                         cs_set_user_model(index, const model[CS_CT_URBAN])                     }                     else if (cs_get_user_model(index, model[CS_T_LEET], len)                     {                         cs_set_user_model(index, const model[CS_CT_GSG9])                     }                     else if (cs_get_user_model(index, model[CS_T_ARCTIC], len)                     {                         cs_set_user_model(index,const model[CS_CT_GIGN])                     }                     else if (cs_get_user_model(index,model [CS_T_GUERILLA], len)                     {                         cs_set_user_model(index, const model [CS_CT_SAS])                     }                 }             }         }     } }
So far so good?

Xanimos 02-27-2006 17:31

Far from it.

wouter 02-27-2006 17:34

can you give me a hint? :D
thx anyway

Jordan 02-27-2006 17:43

To start, on stuff like cs_get_user_model(index)

The index refers to a player index, which in this case would be id.
Second, don't use if Player(CS_Team_CT) or w/e.

Use this:

Code:
new CsTeams:team = cs_get_user_team(id)


You always have to use id in this case, so it isn't cs_get_user_money, it's cs_get_user_money(id).

And finally I think models are constant from Cstrike so you don't need to put const, or the little [].

Code:
/* Plugin generated by AMXX-Studio */ // say \camouflage // say_team \camouflage // amxx_camouflage <1/0> #include <amxmodx> #include <fun> #include <cstrike> new PLUGIN[]="Camouflage" new AUTHOR[]="wouter" new VERSION[]="1.00" new CTModels[] = {     "CS_CT_URBAN", "CS_CT_GSG9",     "CS_CT_GIGN", "CS_CT_SAS" } new TModels[] = {     "CS_T_TERROR", "CS_T_LEET",     "CS_T_ARCTIC", "CS_T_GUERILLA" } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_camouflage", "cmd_camouflage", ADMIN_SLAY, "<1/0>") // This is an admin command, not a /say command. } public cmd_camouflage(id, level, cid) {     new money = cs_get_user_money(id)     new CsTeams:team = cs_get_user_team(id)     if(!is_user_alive(id) && money < 16000)     {         client_print(id, print_chat, "You are not alive or do not have enough money!")         return PLUGIN_HANDLED;     }         if(team == CS_TEAM_CT)     {         cs_set_user_model(id, TModels)         return PLUGIN_CONTINUE;     }         else if(team == CS_TEAM_T)     {         cs_set_user_model(id, CTModels)         return PLUGIN_CONTINUE;     }     return PLUGIN_HANDLED }

You can try this, although I'm not sure if it will pick a random model.

wouter 02-27-2006 18:06

i'll try to build further on this first thing in the morning.
thx man :up:

Jordan 02-27-2006 18:10

No problem.

wouter 02-28-2006 08:31

ok this is what i got:
Code:
/* Plugin generated by AMXX-Studio */   // say \camouflage   // say_team \camouflage   // amxx_camouflage <1/0>   #include <amxmodx>   #include <fun>   #include <cstrike>   new PLUGIN[]="Camouflage"   new AUTHOR[]="wouter"   new VERSION[]="1.00"   new CTModels[] = {     "urban", "gsg9",  //otherwise: Error: could not load file models/player/CS_CT_URBAN/CS_CT_URBAN.mdl     "gign", "sas" } new TModels[] =   {     "terror", "leet",     "artic", "guerilla" } public plugin_init()       {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_clcmd("say /camouflage", "cmd_camouflage") }   public cmd_camouflage(id, level, cid)       {     new money = cs_get_user_money(id)     new CsTeams:team = cs_get_user_team(id)             if(!is_user_alive(id) && money < 16000)         {         client_print(id, print_chat, "You are not alive or do not have enough money!")         return PLUGIN_HANDLED;     }         if(team == CS_TEAM_CT)           {           cs_set_user_model(id, TModels)         cs_set_user_money(id, cs_get_user_money(id) - 16000)         client_print(id, print_chat, "You have bought a camouflage!")         set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 10.0)         show_hudmessage(id, "You have bought a camouflage!")         return PLUGIN_CONTINUE;     }           else if(team == CS_TEAM_T)           {         cs_set_user_model(id, CTModels)         cs_set_user_money(id, cs_get_user_money(id) - 16000)         client_print(id, print_chat, "You have bought a camouflage!")         set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 10.0)         show_hudmessage(id, "You have bought a camouflage!")         return PLUGIN_CONTINUE;     }     if(is_user_alive(id))  // Dont work         {         cs_reset_user_model(id)         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; } /* To Do: set handycap: slow run => Float: get_user_maxspeed ( index ) / Float: set_user_maxspeed ( index, [ Float:speed = - 1.0 ] )           aim at person: tell in hud: enemy! && allie! => Float: get_user_aiming ( index, &id, &body, [ distance,default 9999 ] ) */
but when i die my model dont reset itself
Code:
if(is_user_alive(id))  // Dont work         {         cs_reset_user_model(id)         return PLUGIN_HANDLED;     }
what did i wrong?
thx

Jordan 02-28-2006 18:02

having

Code:
(is_user_alive(id)) //Says that if the user is alive then something will occur.

Code:
(!is_user_alive(id)) //Says that if the user is dead then something will occur.

All a matter of the ! ;)

[ --<-@ ] Black Rose 02-28-2006 19:48

i think this would work, but even though the files exist dont u need a precache anyways? im not sure bout that...

is this supposed to last only for one round?

Code:
/* Plugin generated by AMXX-Studio */   // say \camouflage   // say_team \camouflage   // amxx_camouflage <1/0>   #include <amxmodx>   #include <fun>   #include <cstrike>   new PLUGIN[]="Camouflage"   new AUTHOR[]="wouter"   new VERSION[]="1.00"   new CTModels[] =   {       "urban", "gsg9",     "gign", "sas" }   new TModels[] =   {       "terror", "leet",     "artic", "guerilla" }   public plugin_init()       {       register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /camouflage", "cmd_camouflage")     register_clcmd("say /camouflage", "cmd_camouflage")     register_cvar("amx_camouflage", "1") }   public cmd_camouflage(id) {     if ( ! get_cvar_num("amxx_camouflage") )         return PLUGIN_HANDLED     new money = cs_get_user_money(id)     new CsTeams:team = cs_get_user_team(id)             if ( !is_user_alive(id) || money < 16000 ) {         client_print(id, print_chat, "You are not alive or do not have enough money!")         return PLUGIN_HANDLED;     }         i = random_num(0,3)         if (team == CS_TEAM_CT) {           cs_set_user_model(id, TModels[i])         cs_set_user_money(id, cs_get_user_money(id) - 16000)         client_print(id, print_chat, "You have bought a camouflage!")         set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 10.0)         show_hudmessage(id, "You have bought a camouflage!")         return PLUGIN_CONTINUE;       }           else if (team == CS_TEAM_T) {           cs_set_user_model(id, CTModels[i])         cs_set_user_money(id, cs_get_user_money(id) - 16000)         client_print(id, print_chat, "You have bought a camouflage!")         set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 10.0)         show_hudmessage(id, "You have bought a camouflage!")         return PLUGIN_CONTINUE;       }         if ( !is_user_alive(id) ) {         cs_reset_user_model(id)         return PLUGIN_HANDLED;     }         return PLUGIN_HANDLED; } /* To Do: set handycap: slow run => Float: get_user_maxspeed ( index ) / Float: set_user_maxspeed ( index, [ Float:speed = - 1.0 ] )   aim at person: tell in hud: enemy! && allie! => Float: get_user_aiming ( index, &id, &body, [ distance,default 9999 ] ) */

Emp` 02-28-2006 21:56

to return their model on death, just register the deathmsg
Code:

register_event("DeathMsg", "user_death", "a")
then make a function like this
Code:

public user_death(id)
{
cs_reset_user_model(id)
}

i would suggest making a bool for if the users bought the camouflage that way your not just reseting everyones models, and it wont interfere with other plugins.

so i would suggest doing something like
Code:

public user_death(id)
{
        if(g_hasCamo[id]){
                cs_reset_user_model(id)
                g_hasCamo[id] = false
        }
}

to make the bool just after the
Code:

new TModels[]
stuff and put
Code:

new bool:g_hasCamo[33]
you would then have to make
Code:

g_hasCamo[id] = true
when they buy it :wink:


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

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