Get Players Speed (+rep)
#1

I have this at a timer which updates every 1 second

pawn Код:
for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new speed = GetSpeed(i);
                if(speed > 200 && PlayerInfo[i][pAdmin] < 1)
                {
                    new string[256];
                    new sendername[MAX_PLAYER_NAME];
                    GetPlayerName(i, sendername, sizeof(sendername));
                    format(string, sizeof(string), "[ACHTUNG] Folgender Spieler hat mцglicherweise Speedhack: [%d]%s - %d km/h",i,sendername,speed);
                    ABroadCast(COLOR_YELLOW,string,1);
                }
            }
        }
    }
And this is the stock to get players speed

pawn Код:
public GetSpeed(id)
{
    new Float:s[4];
    GetVehicleVelocity(GetPlayerVehicleID(id),s[0],s[1],s[2]);
    return floatround(1.61*floatsqroot(floatabs(floatpower(s[0]+s[1]+s[2],2)))*100);
}
The problem is, it won't send a message to admins even if the player is driving 500 km/h, it should send a message to admins if the players reaches over 200 km/h

It compiles without errors and warnings, but it doesn't work

Can anyone help? I'll give +rep
Reply
#2

Код:
if(speed > 200 && PlayerInfo[i][pAdmin] < 1)
Admin Level < (means minus) 1? So it's for players level,should be > 1..?
Reply
#3

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Код:
if(speed > 200 && PlayerInfo[i][pAdmin] < 1)
Admin Level < (means minus) 1? So it's for players level,should be > 1..?
No, he means with that

If player drives over 200km and is NO admin, admins want get a warning message with 'Blabla is driving over 200km+'

Why you dont do?:

pawn Код:
if(speed > 200 && PlayerInfo[i][pAdmin] == 0)
Reply
#4

Change the operator to > as that will then send the message to admins higher than 1.
Reply
#5

Is what im saying. [pAdmin] == 0,like you done,is admin level equal to 0,so i assume it's player level.Starting from 1 it's admin level,0 is players level...
Reply
#6

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Is what im saying. [pAdmin] == 0,like you done,is admin level equal to 0,so i assume it's player level.Starting from 1 it's admin level,0 is players level...
No i think he use an edit and all rp scripts on forum.sa-mp use much pLevel. I use always == 0) and not < 1) but everybody has his own style.

Код:
<= : is lower then and that number
< : is lower then
Reply
#7

Oh thanks guys, i didn't understand the pAdmin line, now i get it, it didn't show because i was an admin
It works now

Thank you, +rep
Reply
#8

Pls be sure that "GetSpeed" has no maximum, so print every second a message in the console like this:
printf("%d is driving more than 200km/h. (%fkm/h)", playerid, speed);

or for you:
printf(%d fдhrt mehr als 200 km/h. (%fkm/h)", playerid, speed);

i hope i have helped you, and im from germany if you want to answer me.

but my english is not so good, thats the reason i dont type much in this forum ^^

(forum.sa-mp.de is better For me <.<)
Reply
#9

Quote:
Originally Posted by sjvt
Посмотреть сообщение
No i think he use an edit and all rp scripts on forum.sa-mp use much pLevel. I use always == 0) and not < 1) but everybody has his own style.

Код:
<= : is lower then and that number
< : is lower then
I know the signals about < and > or <=,i was just explaining.Like all admin systems (i think),level 0 is for players,then 1-2-3-4-5-6 is for admins,so i assumed he use this type of levels,i made that post.

Quote:
Originally Posted by Dripac
Посмотреть сообщение
Oh thanks guys, i didn't understand the pAdmin line, now i get it, it didn't show because i was an admin
It works now

Thank you, +rep
No problem.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)