Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: JhonDude on Oct 03, 2022, 02:29 PM

Title: Setting a Weapon Pickup with Cost.
Post by: JhonDude on Oct 03, 2022, 02:29 PM
Hello Guys!
Im tryna set a Weapon Pickup with some conditions:
1 - When a player touch the pickup, if he's had money, he buy it.
Otherwise, the message: "You need more money" appears.
2 - If player already have the Weapon, the message:
"You do not need buy this weapon again" appears.

The idea is simple, but if the player change the weapon slot,
he buy the same weapon again, even already in use.

How can i fix this?
I try the "player.SetWeaponAtSlot( )" but withouth succes.

My code is something like this:
function onPickupPickedUp( player, pickup )
{
  if( pickup.Model == 366 ) 
{
if(player.Cash < 500) MessagePlayer("[#00cc00] Need enough money!",player);
else{
 player.SetWeapon( 10, 999 );
MessagePlayer(" You got a Pump-Shotgun",player);
}
}
Title: Re: Setting a Weapon Pickup with Cost.
Post by: PSL on Oct 04, 2022, 03:18 AM
function onPickupPickedUp( player, pickup )
{
  if( pickup.Model == 366 ) 
{
if(player.Cash < 500) MessagePlayer("[#00cc00] Need enough money!",player);
else if(player.GetWeaponAtSlot(4)==10) MessagePlayer("[#00cc00] It's a weapon you already have!",player);
else{
 player.SetWeapon( 10, 999 );
MessagePlayer(" You got a Pump-Shotgun",player);
}
}

This link may help you: http://wiki.adtec.ovh/wiki/Scripting/Squirrel/Functions/Player.GetWeaponAtSlot
Title: Re: Setting a Weapon Pickup with Cost.
Post by: JhonDude on Oct 04, 2022, 04:38 PM
Quote from: PSL on Oct 04, 2022, 03:18 AMfunction onPickupPickedUp( player, pickup )
{
  if( pickup.Model == 366 ) 
{
if(player.Cash < 500) MessagePlayer("[#00cc00] Need enough money!",player);
else if(player.GetWeaponAtSlot(4)==10) MessagePlayer("[#00cc00] It's a weapon you already have!",player);
else{
 player.SetWeapon( 10, 999 );
MessagePlayer(" You got a Pump-Shotgun",player);
}
}

This link may help you: http://wiki.adtec.ovh/wiki/Scripting/Squirrel/Functions/Player.GetWeaponAtSlot

Thankyou so much man!
So, the correct syntax is: player.GetWeaponAtSlot( slot )
Can't wait for test this one!

And tnx for the wiki link!
The site content will help me a lot!

I coming soon for show you the results!
Title: Re: Setting a Weapon Pickup with Cost.
Post by: JhonDude on Oct 11, 2022, 02:51 PM
Thank you so much man! It works!
I just create the pickups i wanted in Ammu-Nation, like armor, pistol, and rifles.
It´s a simple Touch N' Buy system.

The code exemple:
PickupPickedUp( player, pickup )
{
  if( pickup.Model == 280 ) 
{
if(player.Cash < 1200) MessagePlayer("[#00cc00] You need $1200 to buy an M4 Rifle!",player);
else if(player.GetWeaponAtSlot(6)==26) MessagePlayer("[#00cc00] You don't need to buy this weapon again!",player);
else{
 player.SetWeapon( 26, 120 );
MessagePlayer(" You buy an M4 Rifle! Thank you!",player);
}
}

The same code works fine to other stuffs like grenades, knifes or Health pickups!
Thanks PSL dude!
CLOSED!
Title: Re: Setting a Weapon Pickup with Cost.
Post by: gamingpro on Jan 28, 2023, 09:56 PM
Pro Please help me i want to post things about script showroom but showing me : note : Waiting For Accept the Moderator but the moderator don,t want to accept