Author Topic: !wep buy  (Read 4067 times)

0 Members and 1 Guest are viewing this topic.

Offline Synx

  • Street Thug
  • *
  • Posts: 27
    • View Profile
!wep buy
« on: April 24, 2011, 09:26:22 pm »
Code: [Select]
}
else if (strcmp(cmd, "!wep", true) == 0) {
new wep;
tmp = strtok(cmdtext, idx);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "USAGE: !wep [WeaponName/ID]");
else {
wep = FindWepIDFromString(tmp);
GivePlayerMoney(playerid, -1000);
   if(wep != 33) SetPlayerWeapon(playerid,wep,9999999);
else SendClientMessage(playerid,COLOR_RED,"You can't get this weapon, sorry.");
}
return 1;
}

I need make when someone want get wep than him remove money // I try no good :D
and if player doesn't have money than he gets mesage "Sorry, you can't get this weapon, weapon costs:1000$ !"

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: !wep buy
« Reply #1 on: April 24, 2011, 10:03:19 pm »
Code: [Select]
else if (strcmp(cmd, "!wep", true) == 0) {
new wep,pmon;
        pmon = GetPlayerMoney(playerid);
tmp = strtok(cmdtext, idx);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "USAGE: !wep [WeaponName/ID]");
else {
wep = FindWepIDFromString(tmp);
SetPlayerMoney(playerid,pmon - 1000);
   if(wep != 33) SetPlayerWeapon(playerid,wep,9999999);
else SendClientMessage(playerid,COLOR_RED,"You can't get this weapon, sorry.");
}
        if(pmon >= 1000) {
           SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs:1000$ !");
         }
return 1;
}

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline Synx

  • Street Thug
  • *
  • Posts: 27
    • View Profile
Re: !wep buy
« Reply #2 on: April 24, 2011, 10:13:15 pm »
Thanks :)

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: !wep buy
« Reply #3 on: April 24, 2011, 10:29:08 pm »
Work ?

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline Synx

  • Street Thug
  • *
  • Posts: 27
    • View Profile
Re: !wep buy
« Reply #4 on: April 24, 2011, 11:15:47 pm »
Quote
   }
   else if (strcmp(cmd, "!wep", true) == 0) {
   new wep,pmon;
        pmon = GetPlayerMoney(playerid);
   tmp = strtok(cmdtext, idx);
   if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
   else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "USAGE: !wep [WeaponName/ID]");
   else {
      wep = FindWepIDFromString(tmp);
      SetPlayerMoney(playerid,pmon - 1000);
        if(wep != 33) SetPlayerWeapon(playerid,wep,9999999);
      else SendClientMessage(playerid,COLOR_RED,"You can't get this weapon, sorry.");
   }
        if(pmon == 0) {
           SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs: 1000$ !");
         }

I fix this...
Quote
if(pmon == 0) {
but when player money is 0 he can still get weapons..
« Last Edit: April 24, 2011, 11:17:28 pm by Synx »

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: !wep buy
« Reply #5 on: April 24, 2011, 11:27:42 pm »
Quote
   }
   else if (strcmp(cmd, "!wep", true) == 0) {
   new wep,pmon;
        pmon = GetPlayerMoney(playerid);
   tmp = strtok(cmdtext, idx);
   if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_RED, "You need to login first!");
   else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "USAGE: !wep [WeaponName/ID]");
   else {
      wep = FindWepIDFromString(tmp);
      SetPlayerMoney(playerid,pmon - 1000);
        if(wep != 33) SetPlayerWeapon(playerid,wep,9999999);
      else SendClientMessage(playerid,COLOR_RED,"You can't get this weapon, sorry.");
   }
        if(pmon == 0) {
           SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs: 1000$ !");
         }

I fix this...
Quote
if(pmon == 0) {
but when player money is 0 he can still get weapons..

That's because it doesn't check if the player's money is 0 first, but checks after it tries to give the player the weapon. By the way, if a weapon costs $1,000, you should check if the player has at least $1,000, and not if they have $0.

Under else if(!strlen(tmp)), use this:
Code: [Select]
else if(pmon < 1000) SendClientMessage(playerid, COLOR_RED, "Sorry, you can't get this weapon. Weapons cost $1,000!");

And then get rid of this:
Code: [Select]
if(pmon == 0){
    SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs: 1000$ !");
}
Do not PM me for support.




Offline Synx

  • Street Thug
  • *
  • Posts: 27
    • View Profile
Re: !wep buy
« Reply #6 on: April 24, 2011, 11:44:08 pm »
Thanks, works!  ;)

-LOCK-