SA-MP Forums Archive
Little coding questions - For general minor queries 5 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little coding questions - For general minor queries 5 (/showthread.php?tid=30938)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46


Re: Little coding questions - For general minor queries 5 - budelis - 01.11.2012

Hi,

I use Map Construction.

But i get error "YOU CAN'T USE MAP EDITOR, WHILE GAME IS RUNNING - CLOSE GTA-SA". But there is not GTA running. And i have all files removed to:

Код:
D://Program Files/Rockstar Games/GTA San Andreas
( HERE IS MY GTA GAME.).



Re: Little coding questions - For general minor queries 5 - KlooP - 01.11.2012

Quote:

pInfo[playerid][newbie] = true;
new file[128], name[128];
GetPlayerName(playerid,name,12;
format(file,128,"players/%s.ini",name);
dini_Create(file);
HowMuchPlayers++;
HowMuchPlayers = pInfo[playerid][id];
dini_Set(file,"slaptazodis",inputtext);
dini_IntSet(file, "id", pInfo[playerid][id]);
Save( playerid );
SendClientMessage(playerid,0xFFFFFFFF,"{eb2142}• Registered.");
new failas[26];
format(failas,26,"serverinformation.ini");
dini_IntSet(failas,"HowMuchPlayers",HowMuchPlayers );

Now when you register a new player, then the variable HowMuchPlayers contribute +1 and under it I want to set the new user id and Set Player Virtual World under id.


Re: Little coding questions - For general minor queries 5 - tyler12 - 01.11.2012

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
I don't think we've gotta loop for this.
pawn Код:
new itext = 0; //Create a variable inorder to get the input text and use it for other case. Starting it as zero as we want to store other text on dialog.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //When a dialog gets a response from one of the player.
{
  if(dialogid == 1) //If the response if for dialogid 1.
  {
   //As your post is talking about DIALOG_STYLE_INPUT, the dialog where we input text so lets take Dialog_style_input dialog.
   if(!response) //When player clicks 2nd button or while pressing ESC on keyboard. '!' refers to negative/wrong  response.
   { //Open brackets to execute functions for negative response.
    //Your functions here.
   }
   else //If it isn't a negative response, which means 'if(response)' and when '!' gets switched by else statement, you don't need to add 'if(response)'
   { //Open brackets to execute function for positive response or while clicking 1st button.
     itext = inputtext; //Here we made our itext variable as the text player entered on that dialog.
     //Other functions.
   }
  } //Closing the bracket which we've opened on 'if(dialogid)'.
  return 1; //Returns the functions.
  }
  return 0; //Like 'OnPlayerCommandText' we need to return 0 here too as returning the callback.
}
Now the variable 'itext' is contains the input text, and if you're using it in the case of players, change the variable 'new itext = 0;' to 'new itext[MAX_PLAYERS] = 0;' and while using it, use it as 'itext[playerid] = inputtext;' on dialog.
And now, the player's itext is the input text.
And you can use it, here's an example.
pawn Код:
CMD:enteredtextindialog(playerid,params[])
{
  new str[128];
  format(str, sizeof(str), "%s", itext[playerid]);
  SendClientMessage(playerid, 0xFF0000FF, str);
  return 1;
}
Hope this will give you an idea.
Don't forget it's itext[playerid] = inputtext;

Quote:
Originally Posted by budelis
Посмотреть сообщение
Hi,

I use Map Construction.

But i get error "YOU CAN'T USE MAP EDITOR, WHILE GAME IS RUNNING - CLOSE GTA-SA". But there is not GTA running. And i have all files removed to:

Код:
D://Program Files/Rockstar Games/GTA San Andreas
( HERE IS MY GTA GAME.).
Open task manager, goto processes and close 'gta_sa.exe'


Re: Little coding questions - For general minor queries 5 - KlooP - 01.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
You increment the variable, then set the variable to something else (which is probably 0 if you're talking about registration).
Can you show it?


mysql is pissing me off - shadownrun - 29.11.2012

offtopic: first post, difficult post panel
offtopic2:I dont speak english very well so may this be agressive to your eyes, so im not responsible to any damage it can do

well, im having problem with a_mysql I really dunno what im doing wrong, some topics i seen says its rellated to wrong #include but I really dunno
Код:
#include <a_samp>
#include <a_mysql>
#include <cpstream>
#include <dini>
Код:
mysql_query("INSERT INTO `users` (`nome`, `senha`) VALUES ('%s', MD5('%s'))", Nome, inputtext);
it just gives me this errors
Код:
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : warning 236: unknown parameter in substitution (incorrect #define pattern)
server.pwn(324) : error 029: invalid expression, assumed zero
server.pwn(324) : warning 215: expression has no effect
server.pwn(324) : error 029: invalid expression, assumed zero
server.pwn(324) : warning 215: expression has no effect
server.pwn(324) : error 029: invalid expression, assumed zero
server.pwn(324) : fatal error 107: too many error messages on one line



Re: Little coding questions - For general minor queries 5 - shadownrun - 29.11.2012

thx for replying [HLF]Southclaw but, theres no macro in my code, if I comment the mysql_query it just works fine
here is my actual gamemode file
http://pastebin.com/cgyGnYH2

it will be a little difficult to understand everything because the comments are brazilian portuguese

from line 20 to 23 is the configuration of the database , works
betwen lines 114 and 145 is the function to connect to the database, its working well
and at line 325 as spected is the my error


Re: Little coding questions - For general minor queries 5 - GiamPy. - 29.11.2012

Try changing:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, 3, "Login", TXT_RL, "Logar", "Cancelar");
In:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Pronto vocк esta registrado \nAgora digite Sua Senha Para Logar-Se", "Logar", "Cancelar");



Re: Little coding questions - For general minor queries 5 - shadownrun - 29.11.2012

DAMM!!!, nevermind thx for the suport the problem was that the mysql_query was deprecated on the R7 version of the BlueG's MySQL Plugin as you can see here, and the wiki wasnt updated ¬¬

Quote:

* = R5, R6 (supports threaded and non-threaded scripts)
** = R7 (supports only threaded scripts)

Quote:

mysql_format( connectionHandle, output[], format[], {Float,_}:... ) *

Quote:

mysql_function_query( connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:... ) **

original fom the plugin creator post
https://sampforum.blast.hk/showthread.php?tid=337810

THX for all the feedback ^^


Re: Little coding questions - For general minor queries 5 - shadownrun - 30.11.2012

offtopic: DONE finally i have all my dini system in my database ...

but im having a new problem how can i put an range to the checpoints because no matter how far i am from it, it still show on the minimap


Re: Little coding questions - For general minor queries 5 - PlayLSX_Founder - 30.11.2012

Use a streamer.


Re: Little coding questions - For general minor queries 5 - shadownrun - 30.11.2012

thx ^^
i think i will be away from this topic now ><


Re: Little coding questions - For general minor queries 5 - shadownrun - 01.12.2012

i dont know, in fact most of the code was made by an friend, but its working fine until now so i think its fine

offtopic: y_less's posts, OVER NINE THOUSAND!!!!


Re: Little coding questions - For general minor queries 5 - Bakr - 07.12.2012

I've been having many problems with memory management in Pawn. Here is one of the many problems I've encountered. Here, it just simply assigned the wrong value with no obvious explanation (I found it in 5000+ lines of code and was thankfully able to narrow it down to this):

https://sampforum.blast.hk/showthread.php?tid=395981


AW: Re: Little coding questions - For general minor queries 5 - Nero_3D - 08.12.2012

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Quick question!


Here's some obviously out of bounds code:

pawn Код:
// CODE
Yeah I know it doesn't compile OR run, but I have encountered (much more complex) code like this running in the past and it ends up putting the data somewhere else (without popping up with "array index out of bounds")


Is this the thing I've seen in some places on this forum called "Memory Leak"? Or is that something else completely...
Pawn will only recognise this if you use the array directly
With natives or costum functions you can reproduce something like that

pawn Код:
#include <a_samp>

new
    arr1[3],
    arr2[4];

stock SetCell(array[], cell, value) {
    return (array[cell] = value);
}

main()
{
    arr2[0] = 0; // if we never use arr2 the compiler would leave it away
    SetCell(arr1, 3, 5); // resulting in an invalid memory error
    printf("%d", arr2[0]); // prints 5
}



Re: Little coding questions - For general minor queries 5 - SomeRandomGuy123 - 13.12.2012

Alright, two questions:
1. How do I make it so PlayeAudioStreamForPlayer is sent within a 5 meter radius when a player types the command?
2. How do I StopAudioStreamForPlayer when it's played for 10 seconds?
Thanks


Re: Little coding questions - For general minor queries 5 - LarzI - 13.12.2012

Quote:
Originally Posted by SomeRandomGuy123
View Post
Alright, two questions:
1. How do I make it so PlayeAudioStreamForPlayer is sent within a 5 meter radius when a player types the command?
2. How do I StopAudioStreamForPlayer when it's played for 10 seconds?
Thanks
1. https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
The function has a parameter called "Float:distance" - set this to 5.0 and you should be good to go.

2. https://sampwiki.blast.hk/wiki/SetTimerEx


Re: Little coding questions - For general minor queries 5 - Lordzy - 13.12.2012

Hello,
How do the CallLocalFunction and CallRemoteFunction differ from each other? I saw in wiki that CallRemoteFunction is to call a function created. But I tried both of those functions and saw they do perform like how the other performs. So, isn't there any difference between them?


Re: Little coding questions - For general minor queries 5 - AndreT - 13.12.2012

The difference is that CallLocalFunction is not able to find any functions from other scripts on the server. For example if you have a public function "DoSomething" in one filterscript, you can do CallRemoteFunction("DoSomething", ...) in the gamemode or any other filterscripts (and undoubtedly the same filterscript as well). But CallLocalFunction would not work for functions outside of the loaded script's space.

CallRemoteFunction can be used to share data between scripts for example, but I'm fairly sure PVars (or perhaps GVars from Incognito's plugin or globalized versions of the datasets created using the CSTL plugin) do a better job at this.


Re: Little coding questions - For general minor queries 5 - Lordzy - 13.12.2012

Quote:
Originally Posted by AndreT
View Post
The difference is that CallLocalFunction is not able to find any functions from other scripts on the server. For example if you have a public function "DoSomething" in one filterscript, you can do CallRemoteFunction("DoSomething", ...) in the gamemode or any other filterscripts (and undoubtedly the same filterscript as well). But CallLocalFunction would not work for functions outside of the loaded script's space.

CallRemoteFunction can be used to share data between scripts for example, but I'm fairly sure PVars (or perhaps GVars from Incognito's plugin or globalized versions of the datasets created using the CSTL plugin) do a better job at this.
Oh, thanks.


Re: Little coding questions - For general minor queries 5 - LarzI - 13.12.2012

I'm going to elaborate on Lordz question: When, and why, would one use CallLocalFunction? I've never seemed to understand the usage of it. The reason why I don't understand? Well let's say you're going to use a function - thus call it - you can simply just do
pawn Code:
funcName(arg1);