Vice City Multiplayer
November 14, 2018, 02:12:47 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: LC:MP 0.3z Released! http://forum.vicecitymultiplayer.com/index.php?topic=251.0
 
   Home   Help Search Members Login Register  
Pages: [1]
  Print  
Author Topic: !wep buy  (Read 791 times)
0 Members and 1 Guest are viewing this topic.
Synx
Street Thug
*
Offline Offline

Posts: 10


View Profile
« on: April 24, 2011, 07:26:22 pm »

Code:
}
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 Cheesy
and if player doesn't have money than he gets mesage "Sorry, you can't get this weapon, weapon costs:1000$ !"
Logged
sseebbyy
Wiseguy
**
Offline Offline

Posts: 65


View Profile
« Reply #1 on: April 24, 2011, 08:03:19 pm »

Code:
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;
}
Logged
Synx
Street Thug
*
Offline Offline

Posts: 10


View Profile
« Reply #2 on: April 24, 2011, 08:13:15 pm »

Thanks Smiley
Logged
sseebbyy
Wiseguy
**
Offline Offline

Posts: 65


View Profile
« Reply #3 on: April 24, 2011, 08:29:08 pm »

Work ?
Logged
Synx
Street Thug
*
Offline Offline

Posts: 10


View Profile
« Reply #4 on: April 24, 2011, 09: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, 09:17:28 pm by Synx » Logged
stormeus
Administrator
Wiseguy
*****
Offline Offline

Posts: 60


[IT]


View Profile WWW
« Reply #5 on: April 24, 2011, 09: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:
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:
if(pmon == 0){
    SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs: 1000$ !");
}
Logged

Synx
Street Thug
*
Offline Offline

Posts: 10


View Profile
« Reply #6 on: April 24, 2011, 09:44:08 pm »

Thanks, works!  Wink

-LOCK-
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!