[Help] How can I do this?
#1

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/buydeagle", cmdtext, true, 10) == 0)
	{
	if(IsPlayerInRangeOfPoint(playerid, 5, 308.0848,-141.4177,999.6016))
	{
	GetPlayerMoneyNew(playerid);
	GivePlayerWeapon(playerid, 24, 10);
	GivePlayerMoneyNew(playerid, -2500);
	SetPlayerAmmo(playerid, 2, 10);
	}
	return 1;
}
	if (strcmp("/buyshotgun", cmdtext, true, 10) == 0)
	{
	if(IsPlayerInRangeOfPoint(playerid, 5, 308.0848,-141.4177,999.6016))
	{
	GetPlayerMoneyNew(playerid);
	GivePlayerWeapon(playerid, 25, 20);
	GivePlayerMoneyNew(playerid, -1500);
	SetPlayerAmmo(playerid, 3, 20);
 	}
	return 1;
}
	if (strcmp("/buycolt", cmdtext, true, 10) == 0)
	{
	if(IsPlayerInRangeOfPoint(playerid, 5, 308.0848,-141.4177,999.6016))
	{
	GetPlayerMoneyNew(playerid);
	GivePlayerWeapon(playerid, 22, 30);
	GivePlayerMoneyNew(playerid, -1000);
	SetPlayerAmmo(playerid, 2, 30);
	}
	return 1;
}
	return 1;
}
The code is working fine , but I want it so that it checks the players money:
Код:
GetPlayerMoneyNew(playerid);
And then if the player doesn't have the money it doesn't let them buy . I just need the part where if they don't have the money they cant buy from the store. Atm it makes the money negative if you don't have enough money :/. Thanks for reading and hopefully someone can help ! And if I am doing anything wrong in the code please tell me ^-^ thanks for reading again!
Reply
#2

pawn Код:
if (strcmp("/buydeagle", cmdtext, true, 10) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, 308.0848,-141.4177,999.6016))
        {
            if(GetPlayerMoneyNew(playerid) >= 2500)
            {
                GetPlayerMoneyNew(playerid);
                GivePlayerWeapon(playerid, 24, 10);
                GivePlayerMoneyNew(playerid, -2500);
                SetPlayerAmmo(playerid, 2, 10);
            }
            else
            {
                SendClientMessage(playerid, CHANGE_COLOR," You don't have 2500$");
            }
        }
    }
Try this, if work, follow my example
Reply
#3

Thank you very much you solved my problem ^-^ also where do I find the:
>= or <= and stuff? So I know which one is which and which means greater and which means lower and stuff is there like a tutorial ?
Reply
#4

It's obvious.

GetPlayerMoney( playerid ) <= 5000
You can read that like this
I have $10.000 in my [pocket, and i check ( <= ) if i have less than / or 5000.

Same goes for >=.
== is i have 5000 in pocket and i need 5000.
Reply
#5

oh ok does anyone know how to make it so that if someone spawns a weapon with

GivePlayerWeapon they get banned? And maybe I can change my normal GivePlayerWeapon to GivePlayerWeaponNew so that hackers cant spawn their own weapons without buying it in the store ?
Reply
#6

Quote:
Originally Posted by XoSarahMoX
Посмотреть сообщение
oh ok does anyone know how to make it so that if someone spawns a weapon with

GivePlayerWeapon they get banned? And maybe I can change my normal GivePlayerWeapon to GivePlayerWeaponNew so that hackers cant spawn their own weapons without buying it in the store ?
Check an anti-hacking script, a good script is JunkBuster


https://sampforum.blast.hk/showthread.php?tid=71877
Reply
#7

< less than

> greater than

= equals to

<= less than or equals to

>= greater than or equals to
Reply
#8

Quote:
Originally Posted by marinov
Посмотреть сообщение
< less than

> greater than

= equals to

<= less than or equals to

>= greater than or equals to
Actually,
= results
== equals to
Reply
#9

I looked at the junkbuster thing and it didnt work on my script I want to somehow change the normal GivePlayerWeapon thing to something like GivePlayerWeaponNew anyone know how to do that?
Reply
#10

Quote:
Originally Posted by XoSarahMoX
Посмотреть сообщение
I looked at the junkbuster thing and it didnt work on my script I want to somehow change the normal GivePlayerWeapon thing to something like GivePlayerWeaponNew anyone know how to do that?
You could use a hooked version of gPW or use a stock.

Example :
pawn Код:
stock givePlayerWeapon ( playerid, weaponid )
{
    GivePlayerWeapon ( playerid, weaponid, 134122 );
    return 1;
}
Reply
#11

But wouldnt it just be easier to somehow make the weapons server sided like the money?
Atm I replaced my old money value thing with GivePlayerMoneyNew but I want to do the same with the weapons if that is possible if not I will try to look for a tutorial since I am kinda new to pawn .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)