[HELP] 1 question - player speed
#1

Hello samp users, i was wondering if there was a way to find a player's speed, then use that to do something, for example:
if playerspeed >= 30 then after 1 minute, add $1 onto the players cash...


Is this possible? or should i give up trying, i have searched the forum, but made no sence on the things on there.....

Thankyou;
Ben Jarvis (me)
Reply
#2

pawn Код:
stock GetPlayerSpeed(playerid)
{
  new Float:PlayerPos[4];
  if(IsPlayerInAnyVehicle(playerid))
  {
    GetVehicleVelocity(GetPlayerVehicleID(playerid), PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  }
  else
  {
    GetPlayerVelocity(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  }
  PlayerPos[3] = floatsqroot(floatpower(floatabs(PlayerPos[0]), 2.0) + floatpower(floatabs(PlayerPos[1]), 2.0) + floatpower(floatabs(PlayerPos[2]), 2.0)) * 253.3;
  return floatround(PlayerPos[3], float_round);
}
Usage:

pawn Код:
if(GetPlayerSpeed(playerid) == 30) return SendClientMessage(playerid, 0xffffffff, "You are going at a speed of 30....");
Reply
#3

Thanks!
However, how would it ba possible for me to get it so that after 1 minute of being above 30 (assuming the player stays above this speed) it adds $1? Dont ask the reason for this.. its simply something for my server...


Thankyou again!
Ben Jarvis
Reply
#4

please help?
(sorry if im bumping too soon.. but only got tomorrow to finnish this part of script...)
Reply
#5

pawn Код:
new Pseconds[MAX_PLAYERS];

public OnGameModeInit()
{
  SetTimer("PsecondsUpdate", 1000, true);
  return 1;
}

public OnPlayerConnect(playerid)
{
  Pseconds[playerid] = 0;
  return 1;
}
forward PsecondsUpdate();
public PsecondsUpdate()
{
  for(new i=0;i<MAX_PLAYERS();i++)
  {
    if(GetPlayerSpeed(i) > 29)
    {
      Pseconds[i] ++;
    }
    if(Pseconds[i] == 60)
    {
      GivePlayerMoney(i, 1);
      Pseconds[i] = 0;
    }
  }
  return 1;
}
Is the rest.
Reply
#6

Thankyou so so much!!!
Reply
#7

pawn Код:
new Pseconds[MAX_PLAYERS];

public OnGameModeInit()
{
  SetTimer("PsecondsUpdate", 1000, true);
  return 1;
}

public OnPlayerConnect(playerid)
{
  Pseconds[playerid] = 0;
  return 1;
}
forward PsecondsUpdate();
public PsecondsUpdate()
{
  for(new i=0;i<MAX_PLAYERS();i++)
  {
    if(GetPlayerSpeed(i) < 30)
    {
      Pseconds[i] = 0;
    }
    if(GetPlayerSpeed(i) > 29)
    {
      Pseconds[i] ++;
    }
    if(Pseconds[i] == 60)
    {
      GivePlayerMoney(i, 1);
      Pseconds[i] = 0;
    }
  }
  return 1;
}
Added this
pawn Код:
if(GetPlayerSpeed(i) < 30)
{
    Pseconds[i] = 0;
}
So if you are under 30 you will lose the bonus.
Reply
#8

ok.. i tried both your scripts and both bring up the following errors:

Quote:

C:\Users\Administrator\Documents\gm-samp\gm.pwn(752) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Documents\gm-samp\gm.pwn(752) : error 001: expected token: ")", but found ";"
C:\Users\Administrator\Documents\gm-samp\gm.pwn(752) : error 001: expected token: ";", but found ")"
C:\Users\Administrator\Documents\gm-samp\gm.pwn(752) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

4 Errors.

Line 752 is
pawn Код:
for(new i=0;i<MAX_PLAYERS();i++)
Reply
#9

Quote:
Originally Posted by Dark_Kostas
pawn Код:
for(new i=0;i<MAX_PLAYERS();i++)
Should be:

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
Or:

pawn Код:
for(new i = 0; i < GetMaxPlayers(); i++)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)