Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - JhonDude

#1
Morning Guys!
So... I did it!
As I said before, I was trying to call a specific function, which would allow me to buy the vehicle only once.
After that, the vehicle will be free to use by any player.
And it would only be bought again if it was destroyed or sunk.
And as I expected, the script is quite simple!
Well, at least I found a simple solution. ;D

Here is the code:
function onPlayerEnteringVehicle( player, vehicle, door )
{
if (vehicle.Model == 132)
    {
     if (vehicle.IsGhost == false) return true;
     else if (player.Cash < 2500) MessagePlayer("[#00cc00] Need enough money!",player);
        else{
            player.Cash -= 2500;
            MessagePlayer("[#00cc00] You buy a Car! Congratz!",player);
            return true;           
            }
    }
if (vehicle.Model == 141)
    {
     if (vehicle.IsGhost == false) return true;
     else if (player.Cash < 5000) MessagePlayer("[#00cc00] Need enough money!",player);
        else{
            player.Cash -= 5000;
            MessagePlayer("[#00cc00] You buy a Car! Congratz!",player);
            return true;           
            }
    }
}
function onPlayerEnterVehicle( player, vehicle, door )
{
  vehicle.IsGhost = false;
}
function onVehicleRespawn( vehicle )
{
  vehicle.IsGhost = true;   
}

Note that I used "vehicle.IsGhost" instead of "vehicle.Locked".
The second function just didn't work in this case. I don't know wy. ???
But the first function works fine. With a small caveat:
All vehicles spawned are now "Ghost Vehicles".
This means that they lost the effect of collision with other vehicles.
However, once purchased, it returns to the collision effect, and everything goes back to normal.
At least with the vehicle you just bought.
Those that have not yet been purchased remains "Ghost Vehicles".

So, this is it!
That's my solution!
If anyone has a better idea, don't hesitate to let me know.
See u guys! 8)
#2
Hello Guys!
I'm trying to create a simple vehicle shop.
I don't wanna to use cmds, to call the functions.
I wanna to create something more especific.

So, there is my code:
function onPlayerEnteringVehicle(player, vehicle, door)
{
  if (vehicle.Model == 206)
    {
     if (player.Cash < 2500) MessagePlayer("[#00cc00] Need enough money!",player);
     else{
            player.Cash -= 2500;
            MessagePlayer("[#00cc00] You buy a Car! Congratz!",player);
            return true;
            }
    }
}

Works fine, but this functions are called every time i enter the car again.
I don't wanna this!

This function will only be called if the car is destroyed, blown up, or sunk!

The functions will be called once at the first time a player enter in a car!
If player exit and enter again, the system don't reduce your cash.
Cause this cars is already yours.

I want a function that makes the new  purchased car, free for all users!
Even for those who try to steal it!
We are in Vice City after all!
Cars are frequently stolen! 8)

Thanks in advance for your help!
#3
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!
#4
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!
#5
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);
}
}
#6
Quote from: PSL on Sep 21, 2022, 10:00 AMThis function should help you:
Put the GiveCash(player.ID); in onPlayerJoin.
function GiveCash(ID)
{
    local player=FindPlayer(ID);
    if(player)
    {
        player.Cash+=500;
        NewTimer("GiveCash",900000,1,player.ID);
    }
}

Thanks for the help man!
I tryed the script, but withouth sucsses.
Server starts, and crash on me when "GiveCash" function starts.

So i changed the initial idea to a simple one.
Just add some cash pickups over the map. With a respawntime set on 5min.

this will make the player go around the map looking for these points,
if he wants to have some money at the beginning.

So, tnx for the help!
#7
Quote from: EnForcer on Sep 15, 2022, 12:11 PMuse onplayerrequestspawn event and add the requirement of cash like:
if ( player.Cash < 250 ) return false;
else return true;

Hello again!
The script didn't work for me.
I dont know wy.

So, i made this in a simple way:
Just add: player.Cash +=500; in the event: onPlayerJoin
Like this:
==================
onPlayerJoin
{
    player.Cash +=500;
}
==================
Now i want to add a timer on this.
Each player must earn the amount of 500 for every 15 minutes of play.

Thanks in advance for any help!
#8
Tnx so much man!
A nice and simple script!
Waiting to go home and try this one...
I will post here the results!
See ya!
#9
Hello Guys! Im new here!
Starting to create a DM server.
The question is: Is there a way for the character to start with some money?
The ideia is to start with $250 or $500.
How can i do that? Is a simple class edit? Or the scripts are the only way?