|
Originally Posted by Simbad De Zeeman
Hi, i had an old speedometer, and i replaced the GameTextForPlayer(i, strings, 1500, 5); for
Code:
//GameTextForPlayer(i, strings, 1500, 5); TextDrawDestroy(gText); gText = TextDrawCreate(10.0, 100.0, strings); TextDrawShowForPlayer(i, gText); oldpos[i][0] = newpos[i][0]; oldpos[i][1] = newpos[i][1]; then when a new player connects, that player will get the speedo, and the old player's speedo meter dissapear.. did i make a stupid mistake? |
for(new k = 0; k < MAX_PLAYERS; k++) {
for(new gText = 0; gText < MAX_PLAYERS; gText++) {
if(IsPlayerConnected(k)) {
TextDrawDestroy(gText);
gText = TextDrawCreate(10.0, 100.0, strings);
TextDrawShowForPlayer(k, gText);
oldpos[i][0] = newpos[i][0];
oldpos[i][1] = newpos[i][1];
}
}
}
public carhealth() {
new Float:tmp;
new tmpp[256];
new tmppp[256];
for(new i = 0; i < MAX_PLAYERS; i ++) {
if(IsPlayerInAnyVehicle(i)) {
GetVehicleHealth(GetPlayerVehicleID(i), tmp);
format(tmpp,255,"%f",tmp / 10);
valstr(tmppp,strval(tmpp));
TextDrawDestroy(carhp[i]);
carhpshown[i] = 0;
format(tmpp,255,"%d km/h~n~%s%",kmph[i], tmppp);
carhp[i] = TextDrawCreate(500, 380, tmpp);
TextDrawUseBox(carhp[i], 1);
TextDrawBoxColor(carhp[i], 0x88888877);
TextDrawShowForPlayer(i, carhp[i]);
carhpshown[i] = 1;
} else {
if(carhpshown[i] == 1) {
TextDrawDestroy(carhp[i]);
carhpshown[i] = 0;
}
}
}
}
|
Originally Posted by Shield42
When I try to draw numbers, it seems to insert a return. As in, if I coded ("Hello 1, hello 2"), I'd get a TD that looks like this:
Hello 1 hello 2 Any explanation? |
if(strcmp(cmdtext, "/infernus", true)==0)
{
if( PVeh[playerid] > 0 )
{
if(GetPlayerVehicleID(playerid) != PVeh[playerid])
{
if(IsPlayerInAnyVehicle(playerid))
{
RemovePlayerFromVehicle(playerid);
}
HidePlayerInfoTextDraws(playerid);
new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
GetPlayerName(playerid, Name, sizeof( Name ));
PutPlayerInVehicle(playerid, PVeh[playerid], 0);
SetVehiclePos(PVeh[playerid], X, Y, Z);
SetVehicleZAngle(PVeh[playerid], Ang);
SetVehicleHealth(PVeh[playerid], 1000.0);
LinkVehicleToInterior(PVeh[playerid], GetPlayerInterior(playerid));
TextDrawShowForPlayer(playerid, Text:VehicleCalled);
HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
}
else
{
HidePlayerInfoTextDraws(playerid);
TextDrawShowForPlayer(playerid, Text:VehicleError);
HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
}
}
else
{
if(IsPlayerInAnyVehicle(playerid))
{
RemovePlayerFromVehicle(playerid);
}
HidePlayerInfoTextDraws(playerid);
new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
GetPlayerName(playerid, Name, sizeof( Name ));
PVeh[playerid] = CreateVehicle(522, X, Y , Z, Ang, 75,3, 5000000);
PutPlayerInVehicle(playerid, PVeh[playerid], 0);
LinkVehicleToInterior(PVeh[playerid], GetPlayerInterior(playerid));
TextDrawShowForPlayer(playerid, Text:VehicleCreated);
HidePlayerInfoTextDrawst[playerid] = SetTimerEx("HidePlayerInfoTextDraws", 4000, 0, "i", playerid);
SetVehicleParamsForPlayer(PVeh[playerid], playerid, 0, 0);
for(new i=0; i <= MAX_PLAYERS; i++)
{
if ( IsPlayerConnected(i) )
{
if ( i != playerid )
{
SetVehicleParamsForPlayer(PVeh[playerid], i, 0, 1);
}
}
}
}
return 1;
}
// This will create the textdraw at position x:0,y:0 with the text "hey" and it will be stored in "This is my textdraw" player-variable
SetPVarInt(playerid, "This is my textdraw", _:TextDrawCreate(0, 0, "hey"));
// Now, to modify this textdraw in another script, you use for example:
TextDrawSetString(_:GetPVarInt(playerid, "This is my textdraw"), "new text");
|
If you use text draws in filterscripts make sure you destroy them on filterscript exit. Also, if you use filterscripts in your gamemode and in filterscripts, make sure you destroy all of them on gamemode/filterscript exit then recreate them in your filterscripts after the filterscripts are created in your gamemode. If you don't do this, things like /rcon gmx and /rcon reloadfs blah will mess up your text draws.
|