Getplayerspeed, setobjectmaterialtext ?
#1

This sign should show current vehicle speed, but it shows only 0 always Maybe I missed something ? How it looks like :
http://www.part.lt/perziura/20bacd18...c9c5bb9107.png

Code:

Код:
public OnGameModeInit()
{
    new stri[128];
    new objektas = CreateObject(7246, 687.94568, -1756.04565, 16.27477,   0.00000, 0.00000, 252.25433);
    for(new i = 0; i < MAX_PLAYERS; i++)
    format(stri,128,"%d",GetPlayerSpeed(i,true));
    SetObjectMaterialText(objektas,stri, 0, OBJECT_MATERIAL_SIZE_256x128,\
	"Arial", 80, 0, 0xFFFF8200, 0xFF000000, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
}
Reply
#2

You need to update it (timer should to this work)! OnGameModeInit is called when server start and no more .
Reply
#3

Quote:
Originally Posted by doreto
Посмотреть сообщение
You need to update it (timer should to this work)! OnGameModeInit is called when server start and no more .
But if i move code to other callback (this time to onplayerupdate) i get error error 017: undefined symbol "objektas"
Reply
#4

Quote:
Originally Posted by Louris
Посмотреть сообщение
But if i move code to other callback (this time to onplayerupdate) i get error error 017: undefined symbol "objektas"
define "objektas" as global varible
Reply
#5

Quote:
Originally Posted by doreto
Посмотреть сообщение
define "objektas" as global varible
How? Sorry for stupid question, i'm newbie.
Reply
#6

pawn Код:
new object; // global varible , you can use it everywere you wont (every callback)

public OnGameModeInit()
{
    new object; // local varible , you can use it only in OnGameModeInit callback
    return 1;
}
Reply
#7

Quote:
Originally Posted by doreto
Посмотреть сообщение
pawn Код:
new object; // global varible , you can use it everywere you wont (every callback)

public OnGameModeInit()
{
    new object; // local varible , you can use it only in OnGameModeInit callback
    return 1;
}
warning 219: local variable "objektas" shadows a variable at a preceding level
warning 204: symbol is assigned a value that is never used: "objektas"

Never used? I just used it on OnPlayerUpdate callback..
Reply
#8

Deleted new object from OnGameModeInit.
Reply
#9

Quote:
Originally Posted by 101
Посмотреть сообщение
Deleted new object from OnGameModeInit.
Thanks! I'll try with timer to update material text and post errors if i had them.
Reply
#10

Mhm, i added timer, now sign flashing every second, but shows 0. What I doing wrong ?

Код:
public OnGameModeInit()
{
    SetTimer("speed", 1000, true);
}

forward speed();
public speed()
{
	new stri[128];
    for(new i = 0; i < MAX_PLAYERS; i++)
    format(stri,128,"%d",GetPlayerSpeed(i,true));
    SetObjectMaterialText(objektas,stri, 0, OBJECT_MATERIAL_SIZE_256x128,\
	"Arial", 80, 0, 0xFFFF8200, 0xFF000000, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)