Little coding questions - For general minor queries 5

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
Ok, so my thread got closed and i got told to get here.. so.. guys what is this object ID?



the object i want is the white object in the picture.
I guess that's cj_smoke_mach, ID 2780.
Reply

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Holy. Mother. Of. God. I'm retarded. No really, I am. Cheers.
Do note that this only works for one digit numbers (0 - 9), as you're just changing the ASCII code of the character. The ASCII ID of '0' is 48, the ID of '3' is 51. So that makes '0' + 3 work. But when you do '0' + 10, it will go to the next character on the ASCII table, which is ':' (the colon).

See the full ASCII table here. (Scroll down a bit)
Reply

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
Do note that this only works for one digit numbers (0 - 9), as you're just changing the ASCII code of the character. The ASCII ID of '0' is 48, the ID of '3' is 51. So that makes '0' + 3 work. But when you do '0' + 10, it will go to the next character on the ASCII table, which is ':' (the colon).

See the full ASCII table here. (Scroll down a bit)
I am fully aware of this, don't worry. I was just not aware that you could do this in PAWN. I'm not THAT retarded :P

When I now know this, I can easily make a conversion function from base10 to any base from 2 up to 36 - not that I know what I'll use it for, but it's cool to know I just can.
Reply

Quote:
Originally Posted by LarzI
Посмотреть сообщение
I am fully aware of this, don't worry. I was just not aware that you could do this in PAWN. I'm not THAT retarded :P

When I now know this, I can easily make a conversion function from base10 to any base from 2 up to 36 - not that I know what I'll use it for, but it's cool to know I just can.
Haha, I'm sorry. It might be useful for saving certain things into INI files, for example 8 cars the player can own. Instead of creating the string "car<number>" 8 times with valstr + strcat or format, you can just do str[3] = 48 + carnumber;
Reply

Hey, how can i make this vehicle spawning command to if a car is empty for 10sec then it is destroyed or something?

Quote:

COMMAND:masin(playerid, params[])
{
#if USE_ADMIN == true
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Sa pead olema RCON admin, et seda CMD kasutada.");
#endif
new Vehicle[50];
if(!sscanf(params, "s[50]", Vehicle))
{
new string[128], Float:Pos[4];
GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
new veh = GetVehicleModelID(Vehicle);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, COLOR_RED, "Vale masina nimi, palun proovi uuesti!");
if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
new PVeh = CreateVehicle(veh, Pos[0], Pos[1]+3, Pos[2]+3, Pos[3]+90, -1, -1, -1);
LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
#if PAY_CMD == true
GivePlayerMoney(playerid, - PAY);
format(string, sizeof string, "Sa spawnisid masina %s. ID: %i.", aVehicleNames[veh - 400], veh);
#else
format(string, sizeof string, "Sa spawnisid masina %s. ID: %i. ", aVehicleNames[veh - 400], veh);
#endif
SendClientMessage(playerid, COLOR_GREEN, string);
} else return SendClientMessage(playerid, COLOR_GREEN, "KASUTUS: /masin [Masina Nimi] ");
return 1;
}

Reply

Quote:
Originally Posted by Hade.
Посмотреть сообщение
Hey, how can i make this vehicle spawning command to if a car is empty for 10sec then it is destroyed or something?
Quote:

COMMAND:masin(playerid, params[])
{
#if USE_ADMIN == true
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Sa pead olema RCON admin, et seda CMD kasutada.");
#endif
new Vehicle[50];
if(!sscanf(params, "s[50]", Vehicle))
{
new string[128], Float:Pos[4];
GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
new veh = GetVehicleModelID(Vehicle);
if(veh < 400 || veh > 611) return SendClientMessage(playerid, COLOR_RED, "Vale masina nimi, palun proovi uuesti!");
if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
new PVeh = CreateVehicle(veh, Pos[0], Pos[1]+3, Pos[2]+3, Pos[3]+90, -1, -1, -1);
LinkVehicleToInterior(PVeh, GetPlayerInterior(playerid)); SetVehicleVirtualWorld(PVeh, GetPlayerVirtualWorld(playerid));
#if PAY_CMD == true
GivePlayerMoney(playerid, - PAY);
format(string, sizeof string, "Sa spawnisid masina %s. ID: %i.", aVehicleNames[veh - 400], veh);
#else
format(string, sizeof string, "Sa spawnisid masina %s. ID: %i. ", aVehicleNames[veh - 400], veh);
#endif
SendClientMessage(playerid, COLOR_GREEN, string);
} else return SendClientMessage(playerid, COLOR_GREEN, "KASUTUS: /masin [Masina Nimi] ");
return 1;
}

use 10 instead of -1 on the last parameter:

CreateVehicle(veh, Pos[0], Pos[1]+3, Pos[2]+3, Pos[3]+90, -1, -1, 10);

Quote:

CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)

respawn_delay The delay until the car is respawned without a driver in seconds.

Reply

is there a way to use ellipsis in multi dimensional arrays?
Код:
new Text:x[a] = {Text:INVALID_TEXT_DRAW,...};
works fine but what if i want to create a 2d array
Код:
new Text:x[a][b] = {{Text:INVALID_TEXT_DRAW,...},...};
does not work for some reason. i do NOT want to loop through!
Reply

okay thanks for your help.
@southclaw: dont think that might be an adequate solution if it's a huge array
Reply

looping through the array is what i do not want to do but it seems as if i dont have a choice :/
Reply

isnt there a way to modify the language (pawn) itself? as far as i know it's open source and i dont know a reason to restrict multiple ellipsis in multidimensional arrays
@southclaw: creating an array and looping it (ongamemodeinit) is quite untidy. you can easily forget some code. you dont know a reason not to use multiple ellipsis in multidimensional arrays do you?
Reply

Quote:
Originally Posted by ******
Посмотреть сообщение
No, that's not true! Using a single variable will probably be faster than using a single function call, but using many variables to replicate a single function call will almost NEVER be faster!
True. I tested this right after posting and noticed an increase of 1.3 seconds when looping valstr and my custom function ~1000000 times, but I forgot to edit my post.
Reply

I'm trying to create checkpoint, it's compiling without errors but I didn't saw checkpoint when I'm in that zone where it should be. Any ideas?

Zone1 = CreateDynamicCP(154.3609, -1951.9204, 51.3438, 3, -1, -1, -1, 100);
Reply

It doesn't relate to coding but does anyone know what are the font names of text in textdraws when font IDs are 1,2 ?

EDIT:
ID 1 - Graphicus DT Bold
ID 2 - Bank Gothic Medium

A big Thank you goes to TEAMFOLLOWBACK.
Reply

// Don't use these lines if it's a filterscript
SetGameModeText("Ryans Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(1, 170,2495.5151,-1686.7885,13.5153,4.1934,24,250,30,250,0,0);
return 1;

What did I do wrong...
yes, im a noob in scripting..
Reply

pawn Code:
SetGameModeText("Ryans Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    AddPlayerClass(170, 2495.5151,-1686.7885,13.5153,4.1934,24,250,30,250,0,0);
    return 1;
The first argument isn't the ID - that part is assigned by itself in the function. The first argument is, however, the model - which appears to be the next number (170), I presume.
Reply

FIXED.
Reply

SetPlayerPos is one position. X Y Z are the coordinates of that said position, and also the three parameters of SetPlayerPos.

Check the example here on how to do so: https://sampwiki.blast.hk/wiki/Random
Reply

FIXED.
Reply

Quote:
Originally Posted by DaRk_RaiN
View Post
I know how that works, but if you just looked to the SetPlayerPos you'd see what i meant, any one else can help?
On the callback 'OnPlayerSpawn' set a short timer (50ms) and on this delay, you can use SetPlayerPos.

Either use a switch statement with 'random()' as the top value and a set of cumulative numbers for the case values, like so:

pawn Code:
switch(3)
{
    case 0:SetPlayerPos(playerid, 0.0, 10.0, 3.0);
    case 1:SetPlayerPos(playerid, 10.0, 0.0, 3.0);
    case 2:SetPlayerPos(playerid, -5.0, 0.0, 3.0);
}
Of you can define the 3-element sets of coordinates inside a multidimensional array and use random to select the first-level cell:

pawn Code:
new Float:gSpawnPositions[3][3]=
{
    {0.0, 10.0, 3.0},
    {10.0, 0.0, 3.0},
    {-5.0, 0.0, 3.0}
};

// On the timer function

    new id = random(sizeof(gSpawnPositions)); // Pick a number between 0 and the highest cell in the array.
    SetPlayerPos(playerid, gSpawnPositions[id][0], gSpawnPositions[id][1], gSpawnPositions[id][2]);

The first method is suitable for if you only use those coordinates once, the second method is good if you want to use the coordinates in multiple places in your script (if you define the array as a global)
Reply

pawn Code:
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER || !CheckNitro(GetPlayerVehicleID(playerid))) return false;
else if ((((newkeys & (4)) == (4)) && ((oldkeys & (4)) != (4)))) AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
else if ((((newkeys & (4)) != (4)) && ((oldkeys & (4)) == (4)))) RemoveVehicleComponent(GetPlayerVehicleID(playerid), 1010);
return 1;
That use Left ALT or LMB to Active the NOS, i want CTRL or Num 0 to Active the NOS, what must i change ?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)