at the weaponthink .. self.lastplayer contains the name of the player who took the gun from that spawn the last time, but its not saving the name
Code:
CreateWeapon(weapon, weaponName, location, angle)
{
weaponModel = getWeaponModel( weapon );
if( weaponModel == "" )
weaponModel = weapon;
if(!isDefined(angle))
angle = 0;
weaponSpawn = spawn( "script_model", location + (0, 0, 35), 1 );
weaponSpawn setModel( weaponModel );
weaponSpawn.angles = angle;
weaponSpawn thread WeaponThink( weapon, weaponName, location, angle );
weaponSpawn thread spinPickup( weaponSpawn );
weaponSpawn thread pickupFX( weaponSpawn, location, level.groundfxgreen );
wait 0.01;
}
WeaponThink(weapon, weaponName, location, angle)
{
self endon("disconnect");
weptrigger = spawn( "trigger_radius", location, 0, 35, 50 );
while(1)
{
weptrigger waittill( "trigger", player );
if(!isDefined(self.lastPlayer))
{
self.lastPlayer = "nobody";
}
if(level.campprotect == 1 && self.lastPlayer == player.name)
{
player iprintlnbold( "Stop camping at the " + weaponName + " spawn." );
warningsleft = 3 - player.warning;
player iprintlnbold( "You've got " + warningsleft + " warnings left till suicide." );
player.warning++;
if(player.warning == 3)
{
player suicide();
}
}
if(distance(location, player.origin) < 50)
{
lastPlayer = player.name;
player.hint = "Press ^3[{+activate}] ^7to pick up " + weaponName;
if(player useButtonPressed())
{
player takeWeapon(player getCurrentWeapon());
player _giveWeapon( weapon );
player switchToWeapon( weapon );
self delete();
weptrigger delete();
level thread weaponRespawnThink(weapon, weaponName, location, angle);
}
}
wait .05;
}
}
weaponRespawnThink(weapon, weaponName, location, angle)
{
unavailable = spawn( "script_origin", location, 1 );
unavailable thread pickupFX( unavailable, location, level.groundfxred );
wait 15;
unavailable delete();
createWeapon(weapon, weaponName, location, angle);
}
(08-10-2011, 12:58)Pozzuh Wrote:Se7en Wrote:Stealed, from cod4 mod ...look who's talking
[Release] Old School Mod v2.2
[Release] Scroll menu