What's new

Solved Need help with editing some code

T

thatitguy

Lobby Hoster
Messages
79
Reaction score
8
Before you start and say i'm trying to edit a menu to take credit, you're wrong. My friends and i play this game mode all the time and the code screws it up.

So right now this code checks if the play has a different weapon in hand, if he does, it makes him gain a bullet. Anytime you climb a ladder or jump over something you gain a bullet. Anyone know how to edit this so if you already have 0 bullets it won't give you another? Changing the 0 to a 1 makes it worse because then they can get a bullet if they lose one.

Code:
oneInTheChamberWeapon()
{
    self endon("death");
    self endon("disconnect");
    for(;;)
    {
        if(self getCurrentWeapon() != "beretta_mp")
        {
            self takeAllWeapons();
            self giveWeapon("beretta_mp");
            self setWeaponAmmoClip("beretta_mp",0);
            self switchToWeapon("beretta_mp");
            self iPrintln("^1Y^2o^3u ^4h^5a^6v^7e ^8n^9o^1w ^2l^3o^4s^5t ^6y^7o^8u^9r ^1b^2u^3l^4l^5e^6t^7s");
        }
        wait .05;
    }
}
 
I

ImOx

(^._.^)ノ
Retired
Messages
9,968
Reaction score
2,962
That implementation seems awfully weird to me.
Like what is that thing even supposed to do? Why would there be an infinite loop checking for what weapon the player currently has?

Well, anyway, so the problem is that when a player is vaulting or climbing they have no weapon in hands and therefore that code takes their weapon away, and gives them that weapon with 0 ammo in the clip?

Well you could just give each player a variable that holds the amount of ammo each player has. Then just expand that if statement to also check the amount of ammo the player has.
But I still don't understand the point of that function. Help me understand the point of it?
 
T

thatitguy

Lobby Hoster
Messages
79
Reaction score
8
That implementation seems awfully weird to me.
Like what is that thing even supposed to do? Why would there be an infinite loop checking for what weapon the player currently has?

Well, anyway, so the problem is that when a player is vaulting or climbing they have no weapon in hands and therefore that code takes their weapon away, and gives them that weapon with 0 ammo in the clip?

Well you could just give each player a variable that holds the amount of ammo each player has. Then just expand that if statement to also check the amount of ammo the player has.
But I still don't understand the point of that function. Help me understand the point of it?
Michael myers. The point of the function is so that if a player decides to pick up a random weapon, it won't let them.
 
T

thatitguy

Lobby Hoster
Messages
79
Reaction score
8
That implementation seems awfully weird to me.
Like what is that thing even supposed to do? Why would there be an infinite loop checking for what weapon the player currently has?

Well, anyway, so the problem is that when a player is vaulting or climbing they have no weapon in hands and therefore that code takes their weapon away, and gives them that weapon with 0 ammo in the clip?

Well you could just give each player a variable that holds the amount of ammo each player has. Then just expand that if statement to also check the amount of ammo the player has.
But I still don't understand the point of that function. Help me understand the point of it?
how would i exactly go about that?
 
I

ImOx

(^._.^)ノ
Retired
Messages
9,968
Reaction score
2,962
Michael myers. The point of the function is so that if a player decides to pick up a random weapon, it won't let them.
There are random weapons on the ground in CoD 4?
Ah, well surely there could be a better implementation for battling that. There probably is even a notification for picking up a weapon (or could create a custom notification for that).
But yeah, that'd require further investigation, which I at least can't be bothered doing.

how would i exactly go about that?
Define the value for each player when they connect, or spawn in for the first time, or something like that. And then increase/decrease the value when a bullet is shot/earned.
Surely not the best approach, but it's what I can quickly think of for that infinite loop implementation, which I personally wouldn't have used.
Maybe Google some other OIC, or similiar, game modes and see what kind of implementation they have.
 
O

OG Wreck

Enthusiast
Messages
29
Reaction score
8
oneInTheChamberWeapon()
{
self endon("death");
self endon("disconnect");
for(;:wink:
{

self takeAllWeapons();
self giveWeapon("beretta_mp");
self switchToWeapon("beretta_mp");
self setWeaponAmmoStock("beretta_mp", 0 );
self setWeaponAmmoClip("beretta_mp", 1 );
self iPrintln("^1Y^2o^3u ^4h^5a^6v^7e ^8n^9o^1w ^2l^3o^4s^5t ^6y^7o^8u^9r ^1b^2u^3l^4l^5e^6t^7s");
}
wait .05;
}
 
I

ImOx

(^._.^)ノ
Retired
Messages
9,968
Reaction score
2,962
oneInTheChamberWeapon()
{
self endon("death");
self endon("disconnect");
for(;:wink:
{

self takeAllWeapons();
self giveWeapon("beretta_mp");
self switchToWeapon("beretta_mp");
self setWeaponAmmoStock("beretta_mp", 0 );
self setWeaponAmmoClip("beretta_mp", 1 );
self iPrintln("^1Y^2o^3u ^4h^5a^6v^7e ^8n^9o^1w ^2l^3o^4s^5t ^6y^7o^8u^9r ^1b^2u^3l^4l^5e^6t^7s");
}
wait .05;
}
So if a player runs out of ammo, he can just vault over something to get a bullet?
Yeah, doesn't sound sensible.
 
Top Bottom