function onPickupPickedUp(player,pickup)
{
if (pickup.Model == 262)
{
pickup.Respawn();
player.GiveWeapon(4,1)
return 1;
}
if ( pickup.Model == 274)
{
if (player.Cash < 250)
{
MessagePlayer("[#ffffff]You dont have enought cash to buy colt45, need $250",player)
pickup.Respawn();
return false;
}
player.GiveWeapon(17,250)
player.Cash -= 250;
SaveAccount(player)
pickup.Respawn()
return 1;
}
if ( pickup.Model == 277)
{
if (player.Cash < 250)
{
MessagePlayer("[#ffffff]You dont have enought cash to buy shotgun, need $900",player)
pickup.Respawn();
return false;
}
player.GiveWeapon(19,70)
player.Cash -= 900;
SaveAccount(player)
pickup.Respawn()
return 1;
}
if (pickup.Model==366)
{
player.Health = 100;
return 1;
}
if (pickup.Model ==368)
{
player.Armour = 100
return 1;
}
if ( pickup.Model == 283)
{
if (player.Cash < 250)
{
MessagePlayer("[#ffffff]You dont have enought cash to buy uzi, you need $500",player)
pickup.Respawn();
return false;
}
player.GiveWeapon(24,200)
player.Cash -= 500;
pickup.Respawn()
SaveAccount(player)
return 1;
}
return 1;
}
doesnt work, i cant pickup the pickups still. no errors in the console
Can you describe a little more as to why you can not pick them up?
if (pickup.Model == 262)
{
pickup.Respawn();
Why are you doing that :o ?
why not? i just cant pick them up, i walk in them, they dont disaper and i dont get weps
Okay I will script something for you, I might change that entire code, Also you can not remove weapon pickups. you can set the alpha. give me a few. I will send a "Untested code" and see if it helps
Pretty lazy with scripting this, But test this and see what happens....
//------------------------------------------------------------------------------
function onPickupPickedUp(player, pickup) {
local cash = player.Cash, iModel = pickup.Model;
switch( iModel ) {
//Nigtht Stick Pickup
case 262:
player.SetWeapon(4,1);
break;
//Colt Pickup
case 274:
if (cash < 250) {
MessagePlayer("[#ffffff]You dont have enought cash to buy colt45, need $250",player);
return false;
}
player.SetWeapon(17,250);
break;
//Chrome Shotgun Pickup
case 277:
if (cash < 250) {
MessagePlayer("[#ffffff]You dont have enought cash to buy shotgun, need $250",player);
return false;
}
player.SetWeapon(19,70)
break;
}
return true;
}
//------------------------------------------------------------------------------
pickup.Remove() it will remove, to respawn pickup.RespawnTime = time in milliseconds
Thanks
@jayant!
:P
/*Weapon Script "Alpha"*/
//------------------------------------------------------------------------------
function RespawnPickups(model, x, y, z, respawn=500) {
local iWeapon = CreatePickup(model, Vector(x, y, z));
iWeapon.RespawnTime = respawn;
return iWeapon;
}
//------------------------------------------------------------------------------
function onScriptLoad() {
RespawnPickups(262, -1111.0, 111.0, 10.0);//Nigtht Stick Pickup
RespawnPickups(274, -1111.0, 111.0, 10.0);//Colt Pickup
RespawnPickups(277, -1111.0, 111.0, 10.0);//Chrome Shotgun Pickup
::print("Weapon.nut loaded");
return true;
}
//------------------------------------------------------------------------------
function onPickupPickedUp(player, pickup) {
local cash = player.Cash, iModel = pickup.Model;
switch( iModel ) {
//Nigtht Stick Pickup
case 262:
player.SetWeapon(4,1);
pickup.Remove();
break;
//Colt Pickup
case 274:
if (cash < 250) {
MessagePlayer("[#ffffff]You dont have enought cash to buy colt45, need $250",player);
return false;
}
player.SetWeapon(17,250);
pickup.Remove();
break;
//Chrome Shotgun Pickup
case 277:
if (cash < 250) {
MessagePlayer("[#ffffff]You dont have enought cash to buy shotgun, need $250",player);
return false;
}
player.SetWeapon(19,70);
pickup.Remove();
break;
}
return true;
}
//------------------------------------------------------------------------------
ill test after 5 days, im not home now, im in czech republic.
Okay :). I'm a little rusty on knowledge BUT on the create weapon function you might need to add
iWeapon.Life = 599;
maybe @Doomkill3r or
@KAKAN will respond to correct me and view that script.
Just use the following syntax to create weapon pickups which will give you the ammo/gun, this was taken from this topic (http://forum.vc-mp.org/?topic=479.msg3186#msg3186). You can fill your own values in it:
CreatePickup( 258 + weapon_ID, world, ammo, position 255, true )
You can also add pickup.RespawnTime = time_in_miliseconds to make the pickup respawn after the desired time
But what about proper removal? That's what I would really like to see. Of does that function cover it? I've done almost exactly similar but the weapons never refreshed. That's why I think iWeapon.Life will help if placed in the right area. Either on player pickup or on weapon function
@Kewun, check your onPickupClaimPicked function.
Check whether it returns true or false. And too, if it has nothing it, just add a return 1; to it or simply add your code to that function.
k
Well
@Kewun feel free to play with my version as well as if you can not recreate the weapons after removal there is one more opportunity,
You could create a loop method, Create some arrays, or you could use a class. And for each weapon pickup create an array so that the server can check the values on that specific weapon model pickup,. If that value is not zero Set that array to 0 and create the weapon pickups for the array values that returned 1.
Depending on how many weapon pickups you have will determine how many arrays you will need and how many times you will use
CreatePickup
for each array, This is slightly tricky, But if you need help I can help you build this with this, Hopefully with help from others from the VCMP community.
It's more complicating to explain but I already know how I would need to do it.
k, wait 5 days. im in czech republic ;c
not works ;c
@Mötley 's code
Quote from: KAKAN on Aug 08, 2016, 01:14 PM@Kewun, check your onPickupClaimPicked function.
Check whether it returns true or false. And too, if it has nothing it, just add a return 1; to it or simply add your code to that function.
added return 1; still not effecs
http://imgur.com/a/tvvqp
I'm going to guess that the weapon is not being set?
If so try to replace with player.GiveWeapon(4);
As well player.SetWeapon(4);
This typically generates a random number if anything, If I recall correctly...
Did you add a cash function to that weapon case? if so remove it as a second test /*if (cash < 250) {
MessagePlayer("[#ffffff]You dont have enough cash to buy colt45, need $250",player);
return false;
}*/
Other than that no clue as of why it would not work. I have not tested anything..
k
still not works
and my pickups are created with following format:
function onScriptLoad()
{
CreatePickup( 274, Vector(368.053, 1050.34, 19.213)) // PISTOL
CreatePickup( 283, Vector(365.96, 1050.13, 19.213)) // UZI
CreatePickup( 277, Vector(363.171, 1050.22, 19.213)) // SHOTGUN
CreatePickup( 366, Vector(385.615, 1210.76, 19.4767)) // HEALTH
CreatePickup( 366, Vector(468.686, 695.558, 12.1433)) // HEALTH
CreatePickup( 262, Vector(407.347, -487.586, 12.3432)) // BASEBALL BAT
CreatePickup( 368, Vector(385.499, -469.809, 12.3432)) // ARMOUR
}
You should be using the create weapon function I uploaded as its fully modifiable. As I plan to create a way to do something like
GetMaxPickups
GetMaxPickups <- 20;
I just need to actually get a blank server copy and do it.
to use in the method of
for ( local i = 0; i < GetMaxPickups; i++ )
to be able to spawn pickups better if needed.
I will get a blank server copy and run some test ;)
Just realized after moving I can not find my Vice city disc so I can not help you at all or script this sorry.
im so stupid.
i had 2x times function onpickup piked up
i fixed my self.. thx to all lol
Quote from: Kewun on Aug 10, 2016, 06:17 PMim so stupid.
i had 2x times function onpickup piked up
i fixed my self.. thx to all lol
Use classes as event handlers( hope you know what I mean )
A clever trick will do your work, also, it's much more reliable since you don't have to worry about the same function being repeated 2 times.