Problem
#1

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?
Reply
#2

Put:

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

Umh no,i used the new to store functions..
Reply
#4

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.
Reply
#5

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.");
        }
Reply
#6

blackwave,tried,i get the same:



Uploaded with ImageShack.us

This happen when i've the money and i enter.
Reply
#7

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
Reply
#8

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.
Reply
#9

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 ";"
Reply
#10

LUV YA eheheh.

Working.Thanks a lot.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)