D1OZZZLY
Дебютант
/php
public OnPlayerConnect(playerid)
{
new PlayerName[30], str[256];
GetPlayerName(playerid, PlayerName, 30);
format(str, 256, "Welcome %s to my server!", PlayerName);
SendClientMessage(playerid, 0xFF9900AA, str);
return 1;
}
/php
Предположим, что подключился игрок с ником (именем) "Player", тогда ему будет написано: "Welcome Player to my server!" .
Цикл
/php
new a = 50;
new b;
main() {
while(b < a) {
for(b=0; b < a; b++ ) {
printf("%d", b);
}
}
}
/php
В действительности пользы нет, но он показывает, как можно использовать циклы for и while. В этом примере Вы используете цикл while, чтобы проверять, меньше ли целочисленная 'b', чем целочисленная 'a'. Пока это так, b будет увеличиваться и его значение будет печататься.
If-Else и Else if
/php
new PlayerCount;
public OnPlayerConnect(playerid) {
PlayerCount++;
if(PlayerCount > 80) {
print("More then 80 players!");
}
else if(PlayerCount == 0) {
print("No players in the server
");
}
else {
printf("There are %d players", PlayerCount);
}
}
/php
Я не думаю, что это нужно объяснять
..
Switch-выражения
/php
new a;
new timer1;
main() { timer1=SetTimer("FunctionIMade", 1000, 1); }
public FunctionIMade() {
a++;
switch(a) {
case 1:
{
print("[XII]");
}
case 2:
{
print("FTW!");
}
case 3:
{
KillTimer(timer1);
}
}
}
/php
public OnPlayerConnect(playerid)
{
new PlayerName[30], str[256];
GetPlayerName(playerid, PlayerName, 30);
format(str, 256, "Welcome %s to my server!", PlayerName);
SendClientMessage(playerid, 0xFF9900AA, str);
return 1;
}
/php
Предположим, что подключился игрок с ником (именем) "Player", тогда ему будет написано: "Welcome Player to my server!" .
Цикл
/php
new a = 50;
new b;
main() {
while(b < a) {
for(b=0; b < a; b++ ) {
printf("%d", b);
}
}
}
/php
В действительности пользы нет, но он показывает, как можно использовать циклы for и while. В этом примере Вы используете цикл while, чтобы проверять, меньше ли целочисленная 'b', чем целочисленная 'a'. Пока это так, b будет увеличиваться и его значение будет печататься.
If-Else и Else if
/php
new PlayerCount;
public OnPlayerConnect(playerid) {
PlayerCount++;
if(PlayerCount > 80) {
print("More then 80 players!");
}
else if(PlayerCount == 0) {
print("No players in the server
}
else {
printf("There are %d players", PlayerCount);
}
}
/php
Я не думаю, что это нужно объяснять
Switch-выражения
/php
new a;
new timer1;
main() { timer1=SetTimer("FunctionIMade", 1000, 1); }
public FunctionIMade() {
a++;
switch(a) {
case 1:
{
print("[XII]");
}
case 2:
{
print("FTW!");
}
case 3:
{
KillTimer(timer1);
}
}
}
/php
Последнее редактирование:
