static variable works, but not the 'new'
#1

PHP код:
// This belongs under OnPlayerUpdate
static str[7/* Works fine, but when "new str[7]" doesn't work at all and GetVehicleSpeed returns 0. */
new Float:speed GetVehicleSpeed(vid,false);
new 
round floatround(speed);
vid GetPlayerVehicleID(playerid);
format(str,sizeof(str),"%i MPH",round);
PlayerTextDrawSetString(playerid,Speed[playerid],str);
printf("(Speed: %i)",round); 
Already so basically this, when 'str' variable is static it returns the correct speed, but when 'str' isn't static the GetVehicleSpeed returns 0 and I don't think the GetVehicleSpeed function needs to be posted here as it works perfectly when the 'str' variable is static.

"Str" variable isn't static:
pawn Код:
[03:00:18] (Speed: 0)
[03:00:18] (Speed: 0)
[03:00:18] (Speed: 0)
[03:00:18] (Speed: 0)
Variable is a static:
pawn Код:
[03:01:21] (Speed: 47)
[03:01:22] (Speed: 48)
[03:01:22] (Speed: 47)
[03:01:22] (Speed: 46)
[03:01:22] (Speed: 46)
[03:01:22] (Speed: 45)
[03:01:22] (Speed: 44)
[03:01:22] (Speed: 43)
Thanks!
Reply


Messages In This Thread
static variable works, but not the 'new' - by DaniceMcHarley - 17.07.2015, 23:54
Re: static variable works, but not the 'new' - by DaniceMcHarley - 18.07.2015, 00:18
Re: static variable works, but not the 'new' - by SickAttack - 18.07.2015, 01:20
Re: static variable works, but not the 'new' - by DaniceMcHarley - 18.07.2015, 09:41

Forum Jump:


Users browsing this thread: 1 Guest(s)