SA-MP Forums Archive
Problem - 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: Problem (/showthread.php?tid=200551)



Problem - Face9000 - 18.12.2010

Hi all,i've this code in OnPlayerStateChange

Код:
if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new veh = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(veh == 520)
        {
            new m = GetPlayerMoney(playerid), cost = 20000;
            SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.");
            if (m < cost) RemovePlayerFromVehicle(playerid);
            else if(m > cost) GivePlayerMoney(playerid,-cost);
            SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
  }
        if(veh == 425)
        {
            new m = GetPlayerMoney(playerid), cost = 35000;
            SendClientMessage(playerid, 0xFFFFFF, "You need 35.000$ to enter in the Hunter.");
            if (m < cost) RemovePlayerFromVehicle(playerid);
            else if(m > cost) GivePlayerMoney(playerid,-cost);
            SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hunter,remember to rape all!");
  }
        if(veh == 432)
        {
            new m = GetPlayerMoney(playerid), cost = 15000;
            SendClientMessage(playerid, 0xFFFFFF, "You need 15.000$ to enter in the Rhino.");
            if (m < cost) RemovePlayerFromVehicle(playerid);
            else if(m > cost) GivePlayerMoney(playerid,-cost);
            SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Rhino.");
  }
  return 1;
}
The code working fine,i just have errors with the Messages.

Example: I dont have the requested $,i enter in a Hydra (example vehicle) and i get the normal message:

Код:
SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.");
And:
Код:
SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
Same with others vehicles,what's the error?


Re: Problem - blackwave - 18.12.2010

Put:

pawn Код:
if(GetPlayerMoney(playerid) < 20000) return (...)



Re: Problem - Face9000 - 18.12.2010

Umh no,i used the new to store functions..


Re: Problem - Benjo - 18.12.2010

You are not running any money-related checks before the line:
Код:
SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.");
Group that line in with the RemovePlayerFromVehicle bit.


Re: Problem - blackwave - 18.12.2010

Maybe this, then?
pawn Код:
new veh = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(veh == 520)
        {
           
            SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.");
            if (GetPlayerMoney(playerid) < 20000) return RemovePlayerFromVehicle(playerid);
            else if(GetPlayerMoney(playerid) > 20000) GivePlayerMoney(playerid,-20000) && SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
        }



Re: Problem - Face9000 - 18.12.2010

blackwave,tried,i get the same:



Uploaded with ImageShack.us

This happen when i've the money and i enter.


Re: Problem - blackwave - 18.12.2010

hm
pawn Код:
new veh = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(veh == 520)
        {
            if (GetPlayerMoney(playerid) < 20000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.")
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 20000)
            {
                GivePlayerMoney(playerid,-20000)
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
            }
        }
Try this one


Re: Problem - Face9000 - 18.12.2010

Umh,i've added Hunter and Rhino (With different prices)

The code is now :

Код:
if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new veh = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(veh == 520)
        {
            if (GetPlayerMoney(playerid) < 20000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.")
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 20000)
            {
                GivePlayerMoney(playerid,-20000)
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
            }
        }
        if(veh == 425)
        {
            if (GetPlayerMoney(playerid) < 35000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 35.000$ to enter in the Hunter.")
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 35000)
            {
                GivePlayerMoney(playerid,-35000)
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hunter.");
            }
        }
       if(veh == 432)
        {
            if (GetPlayerMoney(playerid) < 15000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 15.000$ to enter in the Rhino.")
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 15000)
            {
                GivePlayerMoney(playerid,-15000)
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Rhino.");
            }
        }
  return 1;
}
Errors:


Код:
C:\Documents and Settings\k\Desktop\SFWAR.pwn(322) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(327) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(335) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(340) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(348) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\k\Desktop\SFWAR.pwn(353) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
And..thanks for your time & patience.


Re: Problem - blackwave - 18.12.2010

pawn Код:
if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new veh = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(veh == 520)
        {
            if (GetPlayerMoney(playerid) < 20000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 20.000$ to enter in the Hydra.");
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 20000)
            {
                GivePlayerMoney(playerid,-20000);
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hydra.");
            }
        }
        if(veh == 425)
        {
            if (GetPlayerMoney(playerid) < 35000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 35.000$ to enter in the Hunter.");
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 35000)
            {
                GivePlayerMoney(playerid,-35000);
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Hunter.");
            }
        }
       if(veh == 432)
        {
            if (GetPlayerMoney(playerid) < 15000)
            {
                 SendClientMessage(playerid, 0xFFFFFF, "You need 15.000$ to enter in the Rhino.");
                 RemovePlayerFromVehicle(playerid);
            }
            else if(GetPlayerMoney(playerid) > 15000)
            {
                GivePlayerMoney(playerid,-15000);
                SendClientMessage(playerid, 0xFFFFFF, "Enjoy your Rhino.");
            }
        }
  return 1;
}

you forgot the ";"


Re: Problem - Face9000 - 18.12.2010

LUV YA eheheh.

Working.Thanks a lot.