SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/04/2019, 12:43 PM   #4121
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,852
Reputation: 675
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Ermanhaut View Post
Reading a few topics about optimization i've found 'Char-arrays':
pawn Code:
new playerName[MAX_PLAYERS char][MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName{playerid}, MAX_PLAYER_NAME);
printf("%s", playerName{playerid});

The code above would be right according to this topic but pawn-lang compiler rejects it.

Is there any mistakes in my code or is there something else i have to do to use Char-arrays?
An char array only works on the "major dimension" aka the last one because all other dimension before the last one are used for indexing and don't hold any data which could be converted to chars
Nero_3D is online now   Reply With Quote
Old 12/04/2019, 06:04 PM   #4122
v4yne1
Little Clucker
 
Join Date: Feb 2019
Posts: 30
Reputation: 4
Default Re: Little coding questions - For general minor queries 5

i want to make a tower climbing minigame. i thought about using virtual worlds for each player so every player has its own tower to climb on (to prevent crowd). i wonder if using 20 virtual worlds at once will cause any lag on my server? thanks in advance
v4yne1 is offline   Reply With Quote
Old 02/05/2019, 05:20 AM   #4123
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,732
Reputation: 1686
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by v4yne1 View Post
i want to make a tower climbing minigame. i thought about using virtual worlds for each player so every player has its own tower to climb on (to prevent crowd). i wonder if using 20 virtual worlds at once will cause any lag on my server? thanks in advance
That should not be an issue. It might even be faster: when you have 20 players in the same virtual/main world they must all be synced all the time. When everyone is in a seperate world this is not the case.
Atleast that is what I suspect. It seems most logic that way. Correct me if I am wrong, anyone.
Kwarde is online now   Reply With Quote
Old 26/09/2019, 08:31 PM   #4124
MrAuto
Little Clucker
 
Join Date: Sep 2019
Posts: 9
Reputation: 2
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Kwarde View Post
That should not be an issue. It might even be faster: when you have 20 players in the same virtual/main world they must all be synced all the time. When everyone is in a seperate world this is not the case.
Atleast that is what I suspect. It seems most logic that way. Correct me if I am wrong, anyone.
It doesn't matter, if you would let players desync in virtual world then bringing them back would require sync again, that much more complicated then just sync them no matter what. Also players are not sync to each other but to the server itself.

From what i know changing virtual world only affect what players sees, what is loaded for him (objects, cars, other players etc.). It can help if someone has old pc, getting rid of other players models could increese fps for them.

As to the server, it doesn't matter at all how many you use as long as you in the max limit of virtual worlds.
MrAuto is offline   Reply With Quote
Old 10/10/2019, 05:02 PM   #4125
Sh4rp
Little Clucker
 
Join Date: Sep 2019
Location: Italy
Posts: 27
Reputation: 14
Default Re: Little coding questions - For general minor queries 5

Can somebody provide a tutorial on how to create smooth camera sequences using InterpolateCameraPos/LookAt please?
Ex.: I have 7 different coordinates from which the camera needs to pass through in a x amount of time. Atm, with my code, the camera stops and after an undefined amount of seconds it begins it's second transition, same goes for the third, then the fourth, etc.
__________________
Discord contact: @Sharp#1708
Sh4rp is offline   Reply With Quote
Old 03/11/2019, 10:37 PM   #4126
Spectrum
Little Clucker
 
Spectrum's Avatar
 
Join Date: Nov 2019
Posts: 4
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Sh4rp View Post
Can somebody provide a tutorial on how to create smooth camera sequences using InterpolateCameraPos/LookAt please?
Ex.: I have 7 different coordinates from which the camera needs to pass through in a x amount of time. Atm, with my code, the camera stops and after an undefined amount of seconds it begins it's second transition, same goes for the third, then the fourth, etc.
https://forum.sa-mp.com/showthread.php?t=330879

I think this topic will help you.
Spectrum is offline   Reply With Quote
Old 08/12/2019, 08:33 AM   #4127
Ermanhaut
Gangsta
 
Ermanhaut's Avatar
 
Join Date: Apr 2016
Location: Brazil
Posts: 662
Reputation: 47
Default Re: Little coding questions - For general minor queries 5

If i hook OnDialogResponse with ALS method, should i return 0 at the end as said in the Wiki?
Code:
Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.
Code:
#if defined menu_OnDialogResponse
  return menu_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
#else
  return 1; // Should it be 0 or 1 ?
#endif
__________________
try, try and try again
Ermanhaut is offline   Reply With Quote
Old 12/12/2019, 10:03 AM   #4128
=KempeR=
Huge Clucker
 
=KempeR='s Avatar
 
Join Date: Oct 2011
Location: Kyiv, Ukraine
Posts: 257
Reputation: 8
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Ermanhaut View Post
If i hook OnDialogResponse with ALS method, should i return 0 at the end as said in the Wiki?
Code:
Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.
Code:
#if defined menu_OnDialogResponse
  return menu_OnDialogResponse(playerid, dialogid, response, listitem, inputtext);
#else
  return 1; // Should it be 0 or 1 ?
#endif
Yep. You should return 1 when you processed the dialog otherwise (at the end of callback) return 0.
__________________
Dafuq am I still doing in SA-MP in 2019?

Sincerely, Kemper
=KempeR= is offline   Reply With Quote
Old 16/01/2020, 02:44 AM   #4129
Marko Koprivanac
Big Clucker
 
Marko Koprivanac's Avatar
 
Join Date: Feb 2012
Location: Belgrade,Serbia
Posts: 78
Reputation: 0
Default Re: Little coding questions - For general minor queries 5

I need help, updating player passwords won't work

Code:
UpdatePlayerPass(playerid, newpass[])
{
        for(new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
	SHA256_PassHash(newpass, Player[playerid][Salt], Player[playerid][Password], 64);

    mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `Password` = %s, 'Salt' = %e WHERE `ID` = %d LIMIT 1", Player[playerid][Password],Player[playerid][Salt], Player[playerid][ID]);
	mysql_tquery(g_SQL, query);
	return 1;
}
While this code will work perfect:
Code:
UpdatePlayerKills(killerid, killNumber)
{
	if (killerid == INVALID_PLAYER_ID) return 0;
	if (Player[killerid][LoggedIn] == false) return 0;

	Player[killerid][Killovi] += killNumber;
    SetPlayerScore(killerid, GetPlayerScore(killerid) + killNumber);
    
	mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `Killovi` = %d WHERE `ID` = %d LIMIT 1", Player[killerid][Killovi], Player[killerid][ID]);
	mysql_tquery(g_SQL, query);
	return 1;
}
Database works, kills, money, deaths it all saves, but password and salt won't, i have no idea why
Help please
Marko Koprivanac is offline   Reply With Quote
Old 16/01/2020, 05:59 AM   #4130
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: Little coding questions - For general minor queries 5

Quote:
Originally Posted by Marko Koprivanac View Post
I need help, updating player passwords won't work

Code:
UpdatePlayerPass(playerid, newpass[])
{
        for(new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
	SHA256_PassHash(newpass, Player[playerid][Salt], Player[playerid][Password], 64);

    mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `Password` = %s, 'Salt' = %e WHERE `ID` = %d LIMIT 1", Player[playerid][Password],Player[playerid][Salt], Player[playerid][ID]);
	mysql_tquery(g_SQL, query);
	return 1;
}
Use single quotes around strings '%s' and '%e'
By the way, you do not need LIMIT clause if `ID` is PRIMARY KEY (which should be).
__________________
Calisthenics is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a soldier aotumaticly be general when the general dies ? AlbanianGuy Scripting Help 35 13/05/2012 03:35 PM
Minor problem Desert Help Archive 4 17/03/2010 06:24 PM
Counting with mysql queries actiwe Help Archive 2 26/02/2010 02:36 PM
SQL queries using GROUP BY Dabombber Help Archive 1 05/10/2009 07:47 PM


All times are GMT. The time now is 08:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.