UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Upgraded Weapon Problem

HOT
broken avatar :(
Created 6 years ago
by Joeycx
0 Members and 1 Guest are viewing this topic.
4,186 views
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
ah, ok. i missed the price-variable there. However, you still need to change that sethintstring and dont mess with the other lines.

Besides that you need to look for the PaP funtion ( stock-scripts it's in zombiemode_perks but for Harry i wouldn't know ), and the when the player pap's a weapon check it that weapon is allready upgraded or not. If it is the price is 10000, and if it's not the price is 5000.

If you want the hintstring to say either "Upgrade weapon. Cost [5000]." when a player holds a normal weapon, or "Double Upgrade weapon. Cost [10000]." when a player hold an upgraded weapon it's not impossible but it's going to require quite a lot of code for just a hintstring.
You could simply do "Upgrade weapon: Cost [5000]. Double Upgrade: Cost [10000]." and then asjust the cost by checking if the weapon is allready upgraded or not like i mentioned above.
Code Snippet
Plaintext
	cost = 5000;
weapon = player getcurrentweapon();


if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
Last Edit: June 01, 2018, 01:52:28 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: vn
Date Registered: 23 February 2015
Last active: 3 years ago
Posts
208
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
Joeycx's Groups
Joeycx's Contact & Social Links
ah, ok. i missed the price-variable there. However, you still need to change that sethintstring and dont mess with the other lines.

Besides that you need to look for the PaP funtion ( stock-scripts it's in zombiemode_perks but for Harry i wouldn't know ), and the when the player pap's a weapon check it that weapon is allready upgraded or not. If it is the price is 10000, and if it's not the price is 5000.

If you want the hintstring to say either "Upgrade weapon. Cost [5000]." when a player holds a normal weapon, or "Double Upgrade weapon. Cost [10000]." when a player hold an upgraded weapon it's not impossible but it's going to require quite a lot of code for just a hintstring.
You could simply do "Upgrade weapon: Cost [5000]. Double Upgrade: Cost [10000]." and then asjust the cost by checking if the weapon is allready upgraded or not like i mentioned above.
Code Snippet
Plaintext
	cost = 5000;
weapon = player getcurrentweapon();


if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}

It took a while but i finally got it working with the hintstring, so thank you so much bluntstuffy for answering all my questions, this is what i did, so please correct me if i did something wrong that would otherwise mess up things later.
Code Snippet
Plaintext
harrybo21_perks_upgraded_trigger_watcher( machine )
{
machine endon( "machine_removed" );
while( 1 )
{
player = undefined;
self waittill( "trigger", player );

if ( !machine.active || ( isDefined( player.is_drinking ) && player.is_drinking ) || player maps\_laststand::player_is_in_laststand() || player isThrowingGrenade() || player isSwitchingWeapons() )
{
wait .1;
continue;
}
cost = 5000;
        weapon = player getcurrentweapon();


       if( isSubStr( weapon, "_upgraded" ) )
       {
             cost = 10000;
       }
       if ( player.score < cost )
       {
             wait .1;
             continue;
       }
       current_weapon = player getCurrentWeapon();
if( !IsDefined( level.zombie_include_weapons[ current_weapon ] ) || !IsDefined( level.zombie_include_weapons[ current_weapon + "_upgraded" ] ) )
        continue;
                     
                player maps\_zombiemode_score::minus_to_player_score( cost );

self SetHintString( "" );
self stopLoopSound();
light_location = spawn( "script_model", machine.origin + ( 0, 0, 5 ) );
light_location.angles = ( machine.angles + ( 0, 90, 0 ) );
light_location setModel( "tag_origin" );

PlayFxOnTag( level._effect[ "fx_zombie_pap_fx" ], light_location, "tag_origin" );

playsoundatposition( "bottle_dispense3d", machine.origin );
rand = randomintrange( 1, 100 );
if( rand <= 8 )
player thread harrybo21_vending_play_quote( "upgrade_wait" );


player.inventory[ player harrybo21_get_weapon_index( current_weapon ) ] = "none";
player takeWeapon( current_weapon );
player thread do_knuckle_crack();
machine playSound( level.pack_a_punches[ self.script_string ].pap_sting );
weaponmodel = player harrybo21_perks_weapon_upgrade( current_weapon, machine.origin + ( 0, 0, level.pack_a_punches[ self.script_string ].pap_gun_height ), machine.angles + ( 0, 90, 0 ), machine );
               

self playLoopSound( "ticktock_loop" );
self thread harrybo21_perk_wait_for_timeout();
self thread harrybo21_perks_weapon_take_watcher( player, current_weapon, machine );
               

self SetHintString( "Press & hold ^6&&1^7 to take weapon" );

self waittill_either( "pap_timeout", "pap_taken" );
light_location delete();
player thread harrybo21_vending_play_quote( self.script_string );
self.current_weapon = "";
weaponmodel delete();
self stoploopsound();
self playLoopSound( level.pack_a_punches[ self.script_string ].pap_idle_sound );

self SetHintString( "Press & hold ^6&&1^7 to Pack A Punch [Cost: 5000] or Double Pack A Punch [Cost: 10000]" );

self notify( "machine_used" );
}
}

There isn't really a "best answer" so i suggest anyone having this problem as well to read through bluntstuffy's post above.

Last Edit: June 01, 2018, 07:45:33 pm by Joeycx
broken avatar :(
×
broken avatar :(
Location: aupotato
Date Registered: 27 September 2013
Last active: 3 years ago
Posts
588
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
respect the dead

donates greatly appreciated :) paypal.me/F3ARxReaper666
discord server:
https://discord.gg/tsGHW99
×
death_reaper0's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
looks good but didnt see anything that checks if player has enough points to buy, put this after the added part
Code Snippet
Plaintext
		if ( player.score < cost )
{
wait .1;
continue;
}

should look like

Code Snippet
Plaintext
        if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
if ( player.score < cost )
{
wait .1;
continue;
}
broken avatar :(
×
broken avatar :(
Location: vn
Date Registered: 23 February 2015
Last active: 3 years ago
Posts
208
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
Joeycx's Groups
Joeycx's Contact & Social Links
looks good but didnt see anything that checks if player has enough points to buy, put this after the added part
Code Snippet
Plaintext
		if ( player.score < cost )
{
wait .1;
continue;
}

should look like

Code Snippet
Plaintext
        if( isSubStr( weapon, "_upgraded" ) )
{
cost = 10000;
}
if ( player.score < cost )
{
wait .1;
continue;
}

Okay i added it, thanks!

 
Loading ...