• Welcome to Vice City Multiplayer.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - stormeus

#16
Quote from: Aurora on April 24, 2011, 09:08:24 PM
That's solved, but now when I join a Server, My game crashes half-way through the Loading.

Do you have another Vice City or VC:MP window open?
#17
General Discussion / Re: [EK] | **.::GAME OVER::.**
April 24, 2011, 09:42:25 PM
No IP address? How are we going to find it if it's not in the Internet tab?
#18
Quote from: [AoD]NC on April 24, 2011, 11:17:52 AM
Quote from: stormeus on April 24, 2011, 06:24:24 AM
That's why I release my scripts and programs (sometimes) under a Creative Commons license, so that people can alter my work as long as I get attribution and, sometimes, share alike and use the same license.

You think someone notices that ::)?

Everyone steals scripts... But some of them are releasing them as their own work or some release them, but say, that a part of it was created by the author... This is SPARTA! shh, VCMP. If you release a script, you must know, that the source can be easily stolen, or would you like to go and ask the law court for help :)?

Not to say that people are stealing, it's all in good practice to have someone improve or build off another script. What I'm saying is that unless someone wants to go out of their way to put some uber license on their script that only lets cool people use it, they shouldn't be able to claim someone's stealing or make them take down a script based off something they made.

Plus, it's always good to have some legal basis. Not like I'm going to go to the Supreme Court and sue some guy for millions of dollars because he copied a few lines of code. ::)
#19
Part II
Control Structures


Introduction
Control flow is the order that Pawn (and any programming language) runs instructions and functions in. The use of loops and switch blocks can change the flow of a program, and repeat a piece of code or execute code specific to an expression.

If, Else If, Else
Toward the end of Part I, we learned about boolean algebra and comparison operators. Here's how such expressions would be used in Pawn. If, Else If, and Else are control statements, which "control" which pieces of code are run. For example, we might want a piece of code to run only if certain conditions are met.

Going back to our previous example with Alice, let's say we want to see how much a department should be paid based on the department ID. If we say new department is equal to 5, employees should be paid at least $25,000. If they're in department 3, they get paid more than $50,000. Otherwise, they should be paid exactly $40,000. In our main function, we have this so far:


main()
{
new department = 5;
}


This still doesn't tell us how much an employee should be paid in department 5, so we'll come back to this example.

The standard syntax for an if/else statement is:

if(expression)
{
// Expression is true.
// <code to run>
}
else if(expression)
{
// Other expression is true.
// <code to run>
}
else
{
// Neither are true.
// <code to run>
}


Keep in mind that you can have multiple else if statements in one conditional block and that else if statements are optional. Using this and our comparison operators, we can now make a conditional block to see how much a department gets paid, like so:


main()
{
new department = 5;
if(department == 5)
{
print("Employees get paid at least $25,000.");
}
else if(department == 3)
{
print("Employees get paid more than $50,000.");
}
else
{
print("Employees get paid exactly $40,000.");
}
}


For/While Loops and Switch
As well as conditional blocks of code, we can also run a piece of code as long as a given condition is true. For example, let's say we have a list of departments and we want to see how much each department is paid:


  • Department 1 - $10,000
  • Department 2 - $20,000
  • Department 3 - $30,000
  • Department 4 - $40,000
  • Department 5 - $50,000

If we wanted to go through each department, we could use a for or while loop. Let's start with the for loop.

The for loop looks a little something like this:

for(variable = counter; condition; counter++)
{
// <code>
}


Let's break this down.
variable is the variable we want to use as our counter. You can also declare a new variable inline like this:

for(new i = [...]


counter is the number we want to start counting from. Usually this is 0. In our case, it's 1.
condition is a condition we want to fulfill. As long as it's true, the for loop will run.
counter++ increments the counter by one. This can also be counter-- to reduce the counter by one.

In the end we get something like this:

for(new i = 1; i < 5; i++)
{
// <code>
}


With 1 being the first department and 5 being the last. Here's where we're also going to introduce switch blocks. Switch blocks consist of a variable and multiple "cases," which are one line long each. Each case is a possible value for the variable, and a default case can be used if none match.

Syntax for switch blocks

switch(variable)
{
case <case>:
// <one line of code>
case <case>:
// <one line of code>
default:
// <one line of code>
}


With each case being a possible value for variable. Now, let's say we want to get the payroll of a department, between 1 and 5. Here's how our switch block would look:


switch(i)
{
case 1:
print("Department 1 gets paid $10,000");
case 2:
print("Department 2 gets paid $20,000");
case 3:
print("Department 3 gets paid $30,000");
case 4:
print("Department 4 gets paid $40,000");
case 5:
print("Department 5 gets paid $50,000");
default:
print("Unknown department.");
}


After placing this in our for block, we get this:

for(new i = 1; i < 5; i++)
{
switch(i)
{
case 1:
print("Department 1 gets paid $10,000");
case 2:
print("Department 2 gets paid $20,000");
case 3:
print("Department 3 gets paid $30,000");
case 4:
print("Department 4 gets paid $40,000");
case 5:
print("Department 5 gets paid $50,000");
default:
print("Unknown department.");
}
}


Which will go through each department and print their payroll in the console, or "Unknown department." if the department does not exist. This same result can be achieved with a while loop, which executes a piece of code while a certain expression is true.

Syntax of a while loop

while(condition)
{
// <code here>
}


If we declare a variable named i and set it to 1, a while loop could be used like so:


new i = 1;
while(i < 5)
{
switch(i)
{
case 1:
print("Department 1 gets paid $10,000");
case 2:
print("Department 2 gets paid $20,000");
case 3:
print("Department 3 gets paid $30,000");
case 4:
print("Department 4 gets paid $40,000");
case 5:
print("Department 5 gets paid $50,000");
default:
print("Unknown department.");
}
i++;
}


With the i++; placed at the end to add 1 to the variable i so we don't have an endless loop, which can lead to memory leaks or crashes.
#20
Quote from: BIG[H] on April 24, 2011, 06:31:46 AM
VCMP has free will Do what ever you like

Yeah, I don't agree with that. Scripters deserve some credit for their work at times, but what I'm saying is that they shouldn't have the right to pull down scripts if they never licensed their work.
#21
Support / Re: How to kick
April 24, 2011, 10:09:18 AM
Quote from: asad3man on April 24, 2011, 09:51:06 AM
is this admin login like VC-MP

No, use /c kick instead of /kick
/c kick [player] [reason]
#22
Support / Re: How to kick
April 24, 2011, 09:49:22 AM
Quote from: asad3man on April 24, 2011, 09:48:41 AM
WHere is that script tell me

GUPS is a good starter script you can use to kick with reasons.
http://forum.vicecitymultiplayer.com/index.php?topic=1666.0
#23
Support / Re: How to kick
April 24, 2011, 09:48:06 AM
Quote from: asad3man on April 24, 2011, 09:46:32 AM
Thanx but how to kick withreason

You need to get or write a script that can do that.
#24
Support / Re: How to kick
April 24, 2011, 09:43:44 AM
Quote from: asad3man on April 24, 2011, 09:30:30 AM
hey problem !

What is the pass of admin and what is rcon and What is that Commadns Strike how to do

RCON is for server administration. The password is in server.cfg where it says "rcon_password"
When you get the password, type /admin password and then /kick playerid

EDIT: Strike beat me to it
#25
Part I
Concepts of Pawn


Welcome to the absolute beginner's guide to Pawn! Before you can get into the nooks and crannies of Pawn, first we have to learn about the concepts of Pawn and programming in General.

Introduction
Pawn is an embeddable programming language and has a C-like syntax. Pawn was designed as an embeddable programming language, and is now used by projects like AMX Mod X, SA:MP, and, of course, VC:MP. Pawn scripts need to be compiled, or translate source code into computer-readable instructions. Pawn scripts have a structured flow, which means instructions are run one after another, but control statements can change what instructions come next.

The Compiler
The compiler translates source code into computer-readable code which will get run by the server. To use the compiler, you can download Pawno from the SA:MP server package, then go to Build > Compile. I recommend you use Pawno for this tutorial series so you can compile your test scripts and get compiler feedback if anything's wrong with the code.

Basic Program Structure
A very basic "Hello World" Pawn script would look like this:

main()
{
    print("Hello World!");
}


The main() function is the entry-point for the script, or where the program starts. The print() function writes a line of text in the console. The main() function doesn't concern us much in VC:MP scripting, but is good for printing script copyrights.

Note how the end of the Hello World line ends with a semicolon (;), but the rest of the code does not. That is because semicolons define where commands end, whereas control flow contains commands.

Variables
Variables are placeholders for information that a script can use, and can be changed at any time by the script. Variables are given names so we can not only get the variable's value, but so that we can also change it later if we need to. Variables can be assigned types so that their values can only be of a given type. Some common types are:


  • Integer: Sometimes represented as int, this is any integer or "whole" number.
  • Float: Stores decimals and any real number
  • Character: Or char, stores a letter, number, or punctuation. Arrays of characters create strings.

The only type that needs to be explicitly declared is a float. Otherwise, Pawn will assume that a variable is an integer, and that arrays are either strings or arrays of integers. However, variables still need to be declared at some point in the script. A variable declaration consists of the word new, followed by the name of the variable, and a semicolon. For example:


  • new myInt; defines a new integral variable named "myInt"
  • new Float:myFloat; defines a new floating point number named "myFloat" -- note the Type: prefix.

Boolean
Boolean algebra is when a mathematical expression is evaluated as either true or false. Therefore, a boolean value can only have one of two values: true or false. However, it evaluates entire expressions. Let's take a few expressions into consideration.

If I were to say 3 < (is less than) 6, obviously the statement is true.
If I were to say I am 5' 9" tall, this statement is also true.

However, if I were to say I am 5' 9" tall AND I am President of the United States, boolean logic states that the ENTIRE expression is false. While it may be true that I am 5' 9", I am not the President. Therefore, the entire expression is false.

A similar sentence: I am 5' 9" tall OR I am President of the United States.
Since only one part of the sentence has to be true, the entire sentence is considered true.

Note
0 is considered false, and 1 is considered true.

Boolean Operators
There are three boolean operators: AND, OR, and NOT. In Pawn:


  • AND is written as &&
  • OR is written as ||
  • NOT is written as !

Boolean operators are evaluated like so. For AND, the combination of two "True" values results in "True" while two "False" values results in "True." Any other combinations returns False. For example:

True AND True is true.
True AND False is false.
False AND True is false.
False AND False is true.

For OR, as long as one value is true, the entire statement is true.

True OR True is true.
True OR False is true.
False OR False is false.
False OR True is true.

The AND operator negates the value of an expression.
NOT True is false.
NOT False is true.

Comparison Operators
Boolean expressions most often involve comparison operators to see if they are true or false. These operators are equal to, greater than (or equal to), less than (or equal to), and not equal. In Pawn:


  • Equal to is written as ==
  • Less than is written as <
  • Greater than is written as >
  • Less than or equal to is written as <=
  • Greater than or equal to is written as >=
  • Inequality is written as !=

Comparison operators form expressions that can be evaluated as true or false. For example, Number_of_Students > 30. IF there are more than 30 students in the class, the entire expression is true. Otherwise, it is false.

Combining Boolean and Comparison Operators
We've looked at how boolean and comparison operators work to form expressions. Now, we'll look at how we can combine them to form more complex expressions.

If we wanted to know if there were more than 30 students in a class and if there were more than 30 seats, we could express this as:
Number_of_Students > 30 && Number_of_Seats > 30

Pawn has to determine the boolean (true/false) value of each expression, then use those values to evaluate the expression as a whole. Let's say we declare two new variables:

new Number_of_Students = 35;
new Number_of_Seats = 38;


Pawn will break this down into 35 > 30 && 38 > 30, which then evaluates to TRUE && TRUE. Therefore, the entire expression is true. The following example uses the following assumptions:


  • All employees work in a department.
  • All employees in department 5 have salaries greater than $25,000
  • Alice is an employee in department 5

Consider the truth of these few expressions:

Alice_salary < 25000 && Alice_department == 5
Alice_salary < 25000 is False. Alice_department == 5 is true. False && True is false.

!Alice_salary < 25000
Alice_salary < 25000 is false. NOT FALSE is true.

Appendix I: Mathematical Operators
Pawn offers mathematical operators as well if you wish to do math with scripts, which will come in handy a lot.
Note that "var" is shorthand for variable.

var + var - Addition
var - var - Subtraction
var * var - Multiplication
var / var - Division
var ^ power - Exponentiation
dividend % divisor - Modulus

variable += number - Adds number to variable and saves in variable
variable *= number - Multiplies number to variable and saves in variable
variable -= number - Subtracts number from variable and saves in variable
variable /= number - Divides number into variable and saves in variable

Appendix II: Comments
Comments allow you to make notes in your code to explain to people who might view it, including yourself, what a piece of code does. Comments can be one line long: one-line comments start with // and continue until the line ends. Multi-line comments begin with /* and end with */ and last between the two markers. Anything that is commented is NOT run or compiled.

Examples:
// One-line long comment
/* Multi
* line
* comment
*/
#26
NOTE
This topic is locked to prevent people from ruining the succession of posts while the guide is being written. PM any errors or suggestions to stormeus.


The Absolute Beginner's
Guide to Pawn





Part I: Concepts              Part II: Control Structures             Part III: Arrays and Strings            Part IV: Basic Functions/Constructs           
#27
mIRC/pawn Scripting / Re: Drift Point = Money ?
April 24, 2011, 07:17:21 AM
Quote from: yazeen on April 24, 2011, 07:12:33 AM
Thijin i lov Sql But the prop is it dont have a compiler! can u make 1?

Squirrel isn't a compilable language, so it's impossible to write a compiler for it.
#28
General Discussion / [Debate] Script Copyrighting
April 24, 2011, 06:24:24 AM
I think we should have a little debate over the copyrighting of scripts, mainly because I've been digging through a few old threads and I've seen instances of authors asking people to pull down scripts or flaming them because their scripts are similar or based off of one of theirs. I think this is a topic the community is somewhat divided on, so here goes nothing:

What's your stance on scripts and copyrights?

Personally, I think that unless someone releases a script under a license (which even then is a little harder to enforce), they cannot and should not have the right to tell someone else to take down their script just because it's based off of or looks like one of their scripts. My reason for this is that it blocks people from innovating scripts and improving them in ways the original author may not have thought of. Also, if someone wants to make a script with features similar to another server's, no one should flame the new script author just because they want to make their own interpretation of a popular server.

The development of scripts should be progressive, but authors should have some rights as well. That's why I release my scripts and programs (sometimes) under a Creative Commons license, so that people can alter my work as long as I get attribution and, sometimes, share alike and use the same license.

Note
Everyone is entitled to their own opinions. This thread is for a friendly debate about how (if) scripts should be copyrighted. We can agree to disagree, but please, do NOT flame other people because of what they believe.
#29
Quote from: Harrybob99 on April 23, 2011, 11:31:37 PM
Ehhh, no, in the mss folder there are 10 files, the only .flt in that folder is Reverb3.flt. The other names are Mp3dec.asi, Mssa3d.m3d, Mssa3d2.m3d, Mssds3dh.m3d, etc. I can copy the rest of those other names if that helps. And yes, i'll go look around the forums.

You probably didn't install VC:MP correctly. It should be installed in the same folder as Vice City. Usually that's C:\Program Files\Rockstar Games\Grand Theft Auto Vice City.

If it was installed correctly, there would be a vc-mp.flt in that folder.
#30
Quote from: Skirmant on April 23, 2011, 01:36:43 PM
So you "reverse engineered" the VCMP server? I believe the source code would be worth sharing :P

Not exactly reverse engineering. It's just a wrapper around the VC:MP server that rotates gamemodes. This is pretty much how MMS works:


  • Load multimode.cfg and count each line as ./gamemodes/line.amx
  • Check that each gamemode is valid. Quit if one isn't.
  • Infinite Loop

    • Check that the mode being loaded is valid. If not, use the first mode.
    • Load server.cfg and replace the gamemode0 line with gamemode0 line 1
    • Save server.cfg
    • Try to launch the server. Quit if it doesn't.
    • Wait for it to finish.
    • Close server handles and get ready to use the next mode.
    • Repeat loop.

The source code is already available for download.


Edit: April 23 @ 22:30 (GMT-6)


Updated
Changelog:

  • Stable enough for Beta testing.
  • MAJOR: Linux version has been compiled and is ready for testing.

The probability of a Squirrel release aren't looking so good for the near future. I managed to get a Squirrel server package after a little bit of searching, though the way I see it, the only way to support Squirrel would be to have multiple server installations and rotating through each rotation.

Whoops, I might've been looking at the mIRC server. Squirrel should be do-able.