• Welcome to Vice City Multiplayer.
 

!wep buy

Started by Synx, April 24, 2011, 07:26:22 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Synx

}
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$ !"

sseebbyy

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

Synx


sseebbyy


Synx

#4
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...
Quoteif(pmon == 0) {
but when player money is 0 he can still get weapons..

stormeus

Quote from: Synx 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...
Quoteif(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:

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:

if(pmon == 0){
    SendClientMessage(playerid,COLOR_RED,"Sorry, you can't get this weapon, weapon costs: 1000$ !");
}

Synx

Thanks, works!  ;)

-LOCK-