Little coding questions - For general minor queries 5

Is there a good e-mail plugin for SA-MP or is there possibility to use a Python script in a plugin for SA-MP server?
Reply

I've been working on a script and throughout this process I have 3 questions on my mind...

How would you create your own function that returns multiple variables and stores them inside the function caller?
For example, GetPlayerPos(playerid, x, y, z);

How can you create a function that accepts multiple and different types parameters?
For instance, the function can be called with the first 2 parameters being a float, but there can be situations where it is 6 parameters and them all being a string or integer only. Like this
Code:
testfunction("si", "test", 1.0);
Is there, or is it possible to create a function that triggers functions? CallRemoteFunction triggers callbacks but not functions, which is unfortunate....
Reply

You can trigger functions with CallRemoteFunction/CallLocalFunction, they just must be public, but you can create them.

You can even make dynamic function headers: https://sampwiki.blast.hk/wiki/Getarg

the old sscanf function for example uses this https://sampwiki.blast.hk/wiki/Sscanf_code

But if you want specific help or something, ask more specific or give an direct example pls
Reply

Thanks, that helps me a lot! Although for the CallRemoteFunction, I know it can trigger public functions, but I was hoping there would be a way to trigger native functions like CallNativeFunction("print", "s", "hello world");
Reply

Quote:
Originally Posted by Logic_
View Post
Is there a good e-mail plugin for SA-MP or is there possibility to use a Python script in a plugin for SA-MP server?
You could also create a Python script on a web server and post a HTTP request to it.
Reply

this might not be the place to ask for this but..

i need the name of the system that tells me names of different parts of los santos.

for example, im on vinewood - textdraw says 'GPS: Vinewood'
Reply

Quote:
Originally Posted by v4yne1
View Post
this might not be the place to ask for this but..

i need the name of the system that tells me names of different parts of los santos.

for example, im on vinewood - textdraw says 'GPS: Vinewood'
That's Zones include.
Reply

Quote:
Originally Posted by SymonClash
View Post
That's Zones include.
holy moly man you are fast

thanks a lot
Reply

REMOVED
Reply

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?
Reply

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
Reply

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
Reply

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.
Reply

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.
Reply

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.
Reply

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://sampforum.blast.hk/showthread.php?tid=330879

I think this topic will help you.
Reply

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
Reply

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.
Reply

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
Reply

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)