Text trouble
#1

Код:
error 001: expected token: "]", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
public OnPlayerUpdate(playerid)
{
	format(stringelegy[playerid], sizeof(stringelegy[playerid]), "%i MPH", GetVehicleSpeed(elegy[playerid])); //HERE
	SetObjectMaterialText(speedo, stringelegy[playerid], 0, 130, "Arial", 30, 0, -1, 0, 1);
	return 1;
}
Reply
#2

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
Код:
error 001: expected token: "]", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Код:
public OnPlayerUpdate(playerid)
{
	format(stringelegy[playerid], sizeof(stringelegy[playerid]), "%i MPH", GetVehicleSpeed(elegy[playerid])); //HERE
	SetObjectMaterialText(speedo, stringelegy[playerid], 0, 130, "Arial", 30, 0, -1, 0, 1);
	return 1;
}
instead of
Код:
sizeof(stringelegy[playerid])
do
Код:
sizeof(stringelegy[])
and if you want to get the number of rows
Код:
new example[2][20];
printf("%d",sizeof example);//rows
printf("%d",sizeof example[]);//columns
will print "2" and "20"
Reply
#3

Ok next problem.
Test is pulsing very fast - one time object and second time text.
What is wrong?
Reply
#4

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
Ok next problem.
Test is pulsing very fast - one time object and second time text.
What is wrong?
cuz you put it on OnPlayerUpdate

important note from the wiki
Quote:
Originally Posted by wikisamp
This callback is called very frequently per second per player; only use it when you know what it's meant for (or more importantly what it's NOT meant for).
The frequency with which this callback is called for each player varies, depending on what the player is doing. Driving or shooting will trigger a lot more updates than idling.
its getting called about every ms (depending on what you do, driving or just standing)

but i think you only need to execute
that code you have there once, not like 100 times

you could put it in a timer and run it only every second.
i suggest you get YSI and use y_timers
Reply
#5

But here it is cool
https://sampforum.blast.hk/showthread.php?tid=454410
Reply
#6

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
that's just poor.
OnPlayerUpdate should never be used except for things like
detecting health hack or similar jobs.

Anything else just clearly says
Quote:

i dont know how timers work!
lets put shit in OnPlayerUpdate

do it like this:

pawn Код:
#include <YSI\y_timers>     //get YSI: forum.sa-mp.com/showthread.php?t=321092

//global scope:
new Timer:speedoT[MAX_PLAYERS];

//somewhere you want the timer to start.
//for example in OnPlayerStateChange:
speedoT[playerid] = repeat speedo(playerid);//starts the timer
//repeating it in a given interval


//again on global scope:
timer speedo[700](playerid)//will executecode about every 700ms
{
    //put your code here...
    //...
    //and to stop it, we could put something like this inside
    //@ the top of course!
    if(!IsPlayerInAnyVehicle(playerid))
        stop speedoT[playerid];//will stop the timer if player
        //aint in a vehicle.
    return 1;
}
simple
Reply
#7

No, that's not cool. His method is way too different than yours. Do a timer on OnPlayerConnect or wherever you start checking the speed per second, which will probably be the fix for your issue. OnPlayerUpdate will, IMO, create massive lag on your server, so yeah.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)