SA-MP Forums Archive
[Help] How can I do this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] How can I do this? (/showthread.php?tid=193306)



[Help] How can I do this? - XoSarahMoX - 25.11.2010

Код:
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!


Re: [Help] How can I do this? - StreetGT - 25.11.2010

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


Re: [Help] How can I do this? - XoSarahMoX - 25.11.2010

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 ?


Re: [Help] How can I do this? - Zh3r0 - 25.11.2010

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.


Re: [Help] How can I do this? - XoSarahMoX - 25.11.2010

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 ?


Re: [Help] How can I do this? - Zh3r0 - 25.11.2010

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


Re: [Help] How can I do this? - marinov - 25.11.2010

< less than

> greater than

= equals to

<= less than or equals to

>= greater than or equals to


Re: [Help] How can I do this? - Zh3r0 - 25.11.2010

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


Re: [Help] How can I do this? - XoSarahMoX - 25.11.2010

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?


Re: [Help] How can I do this? - Retardedwolf - 25.11.2010

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;
}



Re: [Help] How can I do this? - XoSarahMoX - 25.11.2010

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 .