<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7208008176556358529</id><updated>2024-08-29T02:45:40.144-07:00</updated><title type='text'>SA-MP Scripting</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://samp-scripts.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7208008176556358529/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://samp-scripts.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jeka</name><uri>http://www.blogger.com/profile/03773092136011478128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7208008176556358529.post-7246426981024002943</id><published>2011-05-02T13:35:00.000-07:00</published><updated>2011-05-02T13:35:00.717-07:00</updated><title type='text'>How Does Strcmp work !</title><content type='html'>&lt;hr /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;1. What is Strcmp?&lt;/span&gt;&lt;br /&gt;
- Strcmp stands for String Compare, and all it does is compare 2 strings.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;2.&amp;nbsp;How does it work&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;- strcmp works by taking each characters of a string, and substract it&#39;s ASCII-Code with the ASCII-Code of the character in the other string. So lets say you want to compare the string &quot;samp&quot; with the string &quot;samp&quot;. This is what strcmp will do:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;- Take the first character (&#39;s&#39;) and substract it with the character from the second string (&#39;s&#39;)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;- If the characters are the same, the result of the substraction will be 0 (null)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;- Do this for all characters of the strings&lt;/div&gt;&lt;br /&gt;
If the 2 strings are the same, the total of all the characters substracted from eachother will be 0.&lt;br /&gt;
This is why to compare 2 strings you need to check if the result is 0, not 1.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if(strcmp(&quot;Hello&quot;, &quot;Hello&quot;) == 0)
{
    // Do something if they the same
}
else
{
    // Do something if they are different from another
}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
If the 2 strings are not equal to eachother, strcmp will return the result from the substractions.&lt;br /&gt;
&lt;hr&gt;</content><link rel='replies' type='application/atom+xml' href='http://samp-scripts.blogspot.com/feeds/7246426981024002943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://samp-scripts.blogspot.com/2011/05/how-does-strcmp-work.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7208008176556358529/posts/default/7246426981024002943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7208008176556358529/posts/default/7246426981024002943'/><link rel='alternate' type='text/html' href='http://samp-scripts.blogspot.com/2011/05/how-does-strcmp-work.html' title='How Does Strcmp work !'/><author><name>Jeka</name><uri>http://www.blogger.com/profile/03773092136011478128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7208008176556358529.post-4566882312913208216</id><published>2011-04-28T10:45:00.000-07:00</published><updated>2011-04-28T10:47:03.169-07:00</updated><title type='text'>Making a simple Register/Login dialog.</title><content type='html'>&lt;hr&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;First we will need the &quot;Dini&quot; include, so the information can be saved on &quot;.ini &quot; file!&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;Download and put the &quot;Dini&quot; include in&amp;nbsp;&lt;/span&gt;&lt;/u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/pawno/includes &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #990000;&quot;&gt;folder.&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;u&gt;&lt;br /&gt;
&lt;/u&gt;&lt;br /&gt;
Now... Let&#39;s begin scripting.&lt;br /&gt;
Open Pawno and load your GameMode.&lt;br /&gt;
On top of it we must include the &quot;Dini&quot; file so add :&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;#include &amp;lt;Dini&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;Then, we will identify every dialog with a number like this :&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace;&quot;&gt;#define Register 0
&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;#defin&lt;/span&gt;e L&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;ogged 1&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;Also, we must add a new condition:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;new Login[MAX_PLAYERS];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
Then, we must put this under &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;u&gt;OnPlayerConnect&lt;/u&gt;&lt;/span&gt; :&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Login[playerid] = 0;
new nombre[MAX_PLAYER_NAME], archivo[256];
GetPlayerName(playerid, nombre, sizeof(nombre));
format(archivo, sizeof(archivo), &quot;/Users/%s.ini&quot;, nombre);
if (!dini_Exists(archivo))
{
    ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, &quot;Register&quot;, &quot;He writes your password:&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
}
else
{
    ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, &quot;Login&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
This will check if the player is registered and will show the dialog box for registration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, under&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;the callback &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;u&gt;OnDialogResponse&lt;/u&gt;&lt;/span&gt; we&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;will put the following thing:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if (dialogid == Register)
{
    new nombrejugador[MAX_PLAYER_NAME], archivo[256];
    if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, &quot;Register&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
    if (!response) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, &quot;Register&quot;, &quot;He writes your password:&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
    GetPlayerName(playerid, nombrejugador, sizeof(nombrejugador));
    format(archivo, sizeof(archivo), &quot;/Users/%s.ini&quot;, nombrejugador);
    dini_Create(archivo);
    dini_Set(archivo, &quot;User&quot;, nombrejugador);
    dini_Set(archivo, &quot;Password&quot;, inputtext);
    ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, &quot;Login&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
This will make sure that if a player is not registered, he will get the proper dialog.&lt;br /&gt;
If the dialog is closed it will be shown again, so that the player cannot spawn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing we need is the dialog for the login function.&lt;br /&gt;
So we add this:&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border-bottom-color: rgb(153, 153, 153); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(153, 153, 153); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(153, 153, 153); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(153, 153, 153); border-top-style: dashed; border-top-width: 1px; font-family: &#39;Andale Mono&#39;, &#39;Lucida Console&#39;, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if (dialogid == Logged)
{
    new nombrejugador[MAX_PLAYER_NAME], archivo[256], comprobante[256];
    if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, &quot;Login&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
    if (!response) return ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, &quot;Login&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
    GetPlayerName(playerid, nombrejugador, sizeof(nombrejugador));
    format(archivo, sizeof(archivo), &quot;/Users/%s.ini&quot;, nombrejugador);
    format(comprobante, sizeof(comprobante), &quot;%s&quot;, dini_Get(archivo, &quot;Password&quot;));
    if (!strcmp (inputtext, comprobante))
    {
        Login[playerid] = 1;
    }
    else
    {
        ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, &quot;Login&quot;, &quot;He writes your password&quot;, &quot;Acept&quot;, &quot;Cancel&quot;);
    }
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
Now compile the script and create a new folder called &quot;users&quot; in your &lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Scriptfiles&lt;/span&gt;&lt;/u&gt; folder!&lt;br /&gt;
&lt;br /&gt;
If you do everything properly &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;the script will work&lt;/span&gt; 100%</content><link rel='replies' type='application/atom+xml' href='http://samp-scripts.blogspot.com/feeds/4566882312913208216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://samp-scripts.blogspot.com/2011/04/making-simple-registerlogin-dialog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7208008176556358529/posts/default/4566882312913208216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7208008176556358529/posts/default/4566882312913208216'/><link rel='alternate' type='text/html' href='http://samp-scripts.blogspot.com/2011/04/making-simple-registerlogin-dialog.html' title='Making a simple Register/Login dialog.'/><author><name>Jeka</name><uri>http://www.blogger.com/profile/03773092136011478128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>