09.01.2013, 22:55
Little coding questions - For general minor queries 5
09.01.2013, 22:56
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)
See the full ASCII table here. (Scroll down a bit)
09.01.2013, 23:16
Quote:
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) |
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.
10.01.2013, 12:03
Quote:
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. |
10.01.2013, 17:04
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; } |
11.01.2013, 17:20
Quote:
Hey, how can i make this vehicle spawning command to if a car is empty for 10sec then it is destroyed or something?
Quote:
|
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. |
15.01.2013, 14:09
is there a way to use ellipsis in multi dimensional arrays?
works fine but what if i want to create a 2d array
does not work for some reason. i do NOT want to loop through!
Код:
new Text:x[a] = {Text:INVALID_TEXT_DRAW,...};
Код:
new Text:x[a][b] = {{Text:INVALID_TEXT_DRAW,...},...};
15.01.2013, 14:20
okay thanks for your help.
@southclaw: dont think that might be an adequate solution if it's a huge array
@southclaw: dont think that might be an adequate solution if it's a huge array
15.01.2013, 14:50
looping through the array is what i do not want to do but it seems as if i dont have a choice :/
15.01.2013, 15:16
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?
@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?
16.01.2013, 09:02
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.
16.01.2013, 11:09
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);
Zone1 = CreateDynamicCP(154.3609, -1951.9204, 51.3438, 3, -1, -1, -1, 100);
16.01.2013, 20:54
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.
EDIT:
ID 1 - Graphicus DT Bold
ID 2 - Bank Gothic Medium
A big Thank you goes to TEAMFOLLOWBACK.
18.01.2013, 02:34
// 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..
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..
18.01.2013, 10:54
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;
18.01.2013, 16:42
(
Last edited by DaRk_RaiN; 20/01/2013 at 07:51 PM.
)
FIXED.
18.01.2013, 16:55
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
Check the example here on how to do so: https://sampwiki.blast.hk/wiki/Random
18.01.2013, 19:39
(
Last edited by DaRk_RaiN; 20/01/2013 at 07:51 PM.
)
FIXED.
18.01.2013, 21:54
Quote:
I know how that works, but if you just looked to the SetPlayerPos you'd see what i meant, any one else can help?
|
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);
}
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)
21.01.2013, 09:30
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;
« Next Oldest | Next Newest »
Users browsing this thread: 17 Guest(s)