SA-MP Forums Archive
Help-Need help please. - 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)
+--- Thread: Help-Need help please. (/showthread.php?tid=342965)



Help-Need help please. - Edii - 15.05.2012

SORRY FOR MY ENGLISH

Hello,i got a weapon script,it's ok,i made it to take money but,i want if someone can help me to make that:
If the player want to buy a gun and he don't have enought money send him a message like :
You don't have enought money!
Here is the script:
pawn Код:
#include <a_samp>
#define weapons 4670

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Weapon Spawner by FusiouS loaded ");
    print(" Version: 1.0, Release 1");
    print("--------------------------------------");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/arme", true))

    {
        ShowPlayerDialog(playerid, weapons, DIALOG_STYLE_LIST, "Arme", "Cutit-500$\nBata de Baseball-100$\nDeagle-1000$\nShotgun-1500$\nShotgun de Lupta-2000$\nTec-9-1500$\nMP5-1500$\nAK-47-2500$\nSniper(Luneta)-3000$\nLansator(Agheu)-4000$\nGrenade-5000$\nCocktail Molotov-4000$\nM4A1-3000$", "Alege", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == weapons)
    {
        switch(listitem)
        {
            case 0:
                {
   
                  GivePlayerWeapon(playerid, 4, 1);
                  GivePlayerMoney(playerid,-500);
                 
                 
                }
            case 1:
                {
                  GivePlayerWeapon(playerid, 5, 1);
                  GivePlayerMoney(playerid,-100);
                }
            case 2:
                {
                  GivePlayerWeapon(playerid, 24, 300);
                  GivePlayerMoney(playerid,-1000);
                }
            case 3:
                {
                  GivePlayerWeapon(playerid, 25, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 4:
                {
                  GivePlayerWeapon(playerid, 27, 500);
                  GivePlayerMoney(playerid,-2000);
                }
            case 5:
                {
                  GivePlayerWeapon(playerid, 32, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 6:
                {
                  GivePlayerWeapon(playerid, 29, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 7:
                {
                  GivePlayerWeapon(playerid, 30, 500);
                  GivePlayerMoney(playerid,-2500);
                }
            case 8:
                {
                  GivePlayerWeapon(playerid, 34, 500);
                  GivePlayerMoney(playerid,-3000);
                }
            case 9:
                {
                  GivePlayerWeapon(playerid, 36, 500);
                  GivePlayerMoney(playerid,-4000);
                }
            case 10:
                {
                  GivePlayerWeapon(playerid, 16, 500);
                  GivePlayerMoney(playerid,-5000);
                }
            case 11:
                {
                  GivePlayerWeapon(playerid, 18, 500);
                  GivePlayerMoney(playerid,-4000);
                }
            case 12:
                {
                  GivePlayerWeapon(playerid, 31, 500);
                  GivePlayerMoney(playerid,-3000);
                }
         
           
         
        }
    }
    return 1;
}
And,if someone can help me again (sorry for that,but i'm new in scripting xD)
I want when a player kills another player,i want when he do that he get 2.000$ and 1 point [when press tab and see player's scores]


Thanx.



Re: Help-Need help please. - TheDominator - 15.05.2012

pawn Код:
#include <a_samp>
#define weapons 4670

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Weapon Spawner by FusiouS loaded ");
    print(" Version: 1.0, Release 1");
    print("--------------------------------------");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/arme", true))

    {
        ShowPlayerDialog(playerid, weapons, DIALOG_STYLE_LIST, "Arme", "Cutit-500$\nBata de Baseball-100$\nDeagle-1000$\nShotgun-1500$\nShotgun de Lupta-2000$\nTec-9-1500$\nMP5-1500$\nAK-47-2500$\nSniper(Luneta)-3000$\nLansator(Agheu)-4000$\nGrenade-5000$\nCocktail Molotov-4000$\nM4A1-3000$", "Alege", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == weapons)
    {
        switch(listitem)
        {
            case 0:
                {
                  if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 4, 1);
                  GivePlayerMoney(playerid,-500);
                }
            case 1:
                {
                  if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 5, 1);
                  GivePlayerMoney(playerid,-100);
                }
            case 2:
                {
                  if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 24, 300);
                  GivePlayerMoney(playerid,-1000);
                }
            case 3:
                {
                  if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 25, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 4:
                {
                  if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 27, 500);
                  GivePlayerMoney(playerid,-2000);
                }
            case 5:
                {
                  if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 32, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 6:
                {
                  if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 29, 500);
                  GivePlayerMoney(playerid,-1500);
                }
            case 7:
                {
                  if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 30, 500);
                  GivePlayerMoney(playerid,-2500);
                }
            case 8:
                {
                  if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 34, 500);
                  GivePlayerMoney(playerid,-3000);
                }
            case 9:
                {
                  if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 36, 500);
                  GivePlayerMoney(playerid,-4000);
                }
            case 10:
                {
                  if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 16, 500);
                  GivePlayerMoney(playerid,-5000);
                }
            case 11:
                {
                  if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 18, 500);
                  GivePlayerMoney(playerid,-4000);
                }
            case 12:
                {
                  if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: You have insufficient funds to purchase this weapon.");
                  GivePlayerWeapon(playerid, 31, 500);
                  GivePlayerMoney(playerid,-3000);
                }
        }
    }
    return 1;
}
For giving player money when earning a kill:

pawn Код:
GivePlayerMoney(killerid,2000);
And for score:

pawn Код:
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);



Re: Help-Need help please. - Niko_boy - 15.05.2012

inside each case make it like
pawn Код:
case 0:
{
                 if(GetPlayerMoney(playerid) > 500) return SendClientMessage(playerid,-1,"Not enough money");
                  GivePlayerWeapon(playerid, 4, 1);
                  GivePlayerMoney(playerid,-500);
                 
                 
                }



Re: Help-Need help please. - Edii - 15.05.2012

Thank you soo soo soo much,but can someone can help me with that?:
Quote:

I want when a player kills another player,i want when he do that he get 2.000$ and 1 point [when press tab and see player's scores]




Re: Help-Need help please. - FalconX - 15.05.2012

Here with fixed Indentation:-

pawn Код:
#include <a_samp>
#define weapons 4670

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Weapon Spawner by FusiouS loaded ");
    print(" Version: 1.0, Release 1");
    print("--------------------------------------");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/arme", true))
    {
        ShowPlayerDialog(playerid, weapons, DIALOG_STYLE_LIST, "Arme", "Cutit-500$\nBata de Baseball-100$\nDeagle-1000$\nShotgun-1500$\nShotgun de Lupta-2000$\nTec-9-1500$\nMP5-1500$\nAK-47-2500$\nSniper(Luneta)-3000$\nLansator(Agheu)-4000$\nGrenade-5000$\nCocktail Molotov-4000$\nM4A1-3000$", "Alege", "Cancel");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pCash;
    pCash = GetPlayerMoney(playerid);
    if(dialogid == weapons)
    {
        switch(listitem)
        {
            case 0:
            {
                if(pCash < 500) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 4, 1);
                GivePlayerMoney(playerid,-500);
            }
            case 1:
            {
                if(pCash < 100) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 5, 1);
                GivePlayerMoney(playerid,-100);
            }
            case 2:
            {
                if(pCash < 1000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 24, 300);
                GivePlayerMoney(playerid,-1000);
            }
            case 3:
            {
                if(pCash < -1500) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 25, 500);
                GivePlayerMoney(playerid,-1500);
            }
            case 4:
            {
                if(pCash < 2000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 27, 500);
                GivePlayerMoney(playerid,-2000);
            }
            case 5:
            {
                if(pCash < 1500) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 32, 500);
                GivePlayerMoney(playerid,-1500);
            }
            case 6:
            {
                if(pCash < 1500) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 29, 500);
                GivePlayerMoney(playerid,-1500);
            }
            case 7:
            {
                if(pCash < 2500) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 30, 500);
                GivePlayerMoney(playerid,-2500);
            }
            case 8:
            {
                if(pCash < 3000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 34, 500);
                GivePlayerMoney(playerid,-3000);
            }
            case 9:
            {
                if(pCash < 4000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 36, 500);
                GivePlayerMoney(playerid,-4000);
            }
            case 10:
            {
                if(pCash < 5000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 16, 500);
                GivePlayerMoney(playerid,-5000);
            }
            case 11:
            {
                if(pCash < 4000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 18, 500);
                GivePlayerMoney(playerid,-4000);
            }
            case 12:
            {
                if(pCash < 3000) return SendClientMessage(playerid, -1, "You don't have enough money.");
                GivePlayerWeapon(playerid, 31, 500);
                GivePlayerMoney(playerid,-3000);
            }
        }
    }
    return 1;
}
And heres When killer kills the player he gets 2000 and 1 score.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 score
        GivePlayerMoney(killerid, 2000); // cahs 2000
    }
    return 1;
}

I don't mind if someone correct me x)
-FalconX


Re: Help-Need help please. - TheDominator - 15.05.2012

Check my post and your answer shall be revealed


Re: Help-Need help please. - Edii - 15.05.2012

Everything works perfectly but,how can i save all players points,because when i restart the server they lose all they're points...

And another problem here..
pawn Код:
if (strcmp("/armour", cmdtext, true, 10) == 0)
    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Nu ai destui bani pentru a cumpara armura.");
    GivePlayerMoney(playerid,-1000);
    SetPlayerArmour(playerid,100);
    return 1;
  }
That works but,when a player tips another command that doesn't exist,a command that he/she want it gives that command..For Eg: i type /c` and it give's me 100 armour and takes my moneys


Re: Help-Need help please. - FalconX - 15.05.2012

Quote:
Originally Posted by Edii
Посмотреть сообщение
Everything works perfectly but,how can i save all players points,because when i restart the server they lose all they're points...
You need to use saving system which can be MySQL or other file base system which can be dini, yini etc. You can find tutorials in the SA-MP forums.

And try this:-

pawn Код:
if(!strcmp("/armour", cmdtext))
{
    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Nu ai destui bani pentru a cumpara armura.");
    GivePlayerMoney(playerid,-1000);
    SetPlayerArmour(playerid,100);
    return 1;
}
Also, check your includes/filterscripts if you have a command called "c" in it.

-FalconX


Re: Help-Need help please. - Edii - 15.05.2012

FalconX,that doesn't works,and it's not from my filscripts/includes,i can use any comand i want /dawkdoaw /098251kks1 and gives me /armour...And dont you know a good saving system?
Thanx a lot.


Re: Help-Need help please. - FalconX - 15.05.2012

Remember that you are only using strcmp commands on OnPlayerCommandText and it returns 0 in the end. Like this:-

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0; // this return 0
}
As I've observed people are mostly using DINI or YINI, you can find such systems in the forum here are the links of such tutorials:-

1. dini: https://sampforum.blast.hk/showthread.php?tid=234691
2. yini: https://sampforum.blast.hk/showthread.php?tid=273088

-FalconX