Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 7,251
» Latest member: djjuninho_juninho
» Forum threads: 2,377
» Forum posts: 12,288

Full Statistics

Online Users
There are currently 341 online users.
» 0 Member(s) | 337 Guest(s)
Yandex, Bing, Google, Applebot

Latest Threads
Second Generation Rolepla...
Forum: Advertisements
Last Post: JamesT
Yesterday, 10:28 AM
» Replies: 0
» Views: 14
Servidor RPG profissões
Forum: Advertisements
Last Post: tcharlesmeurer
2025-07-05, 11:35 PM
» Replies: 0
» Views: 16
EVO Anti-Cheat
Forum: Libraries
Last Post: Eduardo_AC
2025-07-05, 11:05 PM
» Replies: 2
» Views: 41
Developer for Hire – Syst...
Forum: Pawn Scripting
Last Post: ejtamovic
2025-07-04, 08:35 AM
» Replies: 0
» Views: 49
Liberty City map
Forum: Pawn Scripting
Last Post: ziyadprogamer
2025-06-28, 04:55 PM
» Replies: 2
» Views: 2,175
GameText styles in open.m...
Forum: Pawn Scripting
Last Post: Miki
2025-06-28, 01:25 PM
» Replies: 1
» Views: 60
Script[gamemodes/gamemode...
Forum: Pawn Scripting
Last Post: Miki
2025-06-27, 05:08 PM
» Replies: 1
» Views: 440
Want to edit my profile n...
Forum: Chat
Last Post: Hera.
2025-06-26, 08:41 PM
» Replies: 1
» Views: 590
Farsi
Forum: Other
Last Post: acc.gangbeni
2025-06-25, 08:21 AM
» Replies: 2
» Views: 3,083
Las Venturas Gang Wars - ...
Forum: Advertisements
Last Post: lvgwgta
2025-06-22, 06:47 PM
» Replies: 0
» Views: 70

 
  Ternary Operator Basics
Posted by: RhaegarX - 2021-01-20, 07:29 PM - Forum: Tutorials - Replies (4)

"Sorry for the bad English, I'm using the translator to do this tutorial."



- What is a ternary operator?



In various situations in programming we need to deal with various scenarios, through conditional structures, such as if, else and switch. However, in some situations we deal with wave situations there are only 2 possible returns.



For example, let's imagine a hypothetical situation, in which if the player is an administrator he wins $ 1500, otherwise he will win $ 500.

We can do this logic using the if and else operator:



PHP Code:
if (PlayerData[playerid][pAdmin] > 0)

{? ? ? ? ? 

? ? 
GivePlayerMoney(playerid1500);





else

{

? ? 
GivePlayerMoney(playerid500);





Now notice that we are making a relatively long structure for a simple action, with only two possibilities. Is there no other way to write this code in a simpler way? Yes, there is, and that is what the ternary operator is for:



PHP Code:
GivePlayerMoney(playerid, (PlayerData[playerid][pAdmin] > 1500 500)); 



Now we did the same action with just one line of code, however let's understand a little bit about how to build a ternary operator.



- How to build a ternary operator?



Building a ternary operator is simple, its own structure is self-explanatory.



PHP Code:
(condition value if true value if false



To better understand, we can see that the '?' acts as an if and the ':' acts as the else.



- In what situations will I use the ternary operator?



This is a relative question, it depends a lot on the type of logic that you will build for your system, but as stated in the first question we will use the ternary operator for situations in which there are only 2 possibilities of return. Remembering that the ternary operator is not limited to returning only number values, but can also return strings and other options.



Example of a string with a ternary operator:



PHP Code:
SendClientMessage(playerid, -1, (playerData[playerid][pAdmin] > "True" "false")); 



- Problems with ternary operator



The main problem with the ternary operator is its structure, which because it is very compact, its structure can be difficult to read by programmers who are not used to it.



- End



This is my first personal authoring tutorial, i hope you like it and criticism will always be welcome!


  TSConnector and some other fce
Posted by: Ardenis - 2021-01-20, 06:46 PM - Forum: Pawn Scripting - Replies (1)

Hey there

the TS_PokeClient function does not work correctly. When someone joins the game, they poke them ?

let's look at the code

Code:
public TSC_OnClientConnect (clientid, nickname [])
{
new str[50];
format(str, sizeof(str), "> %s (%d) has join to our ts3 server", nickname, clientid);
SendClientMessageToAll(-1, str);
TSC_SendClientMessage(clientid, "Yup, here it works");
TSC_PokeClient(clientid, "Welcome"); // But not here, it not poke him but idk why
return 1;
}

http://prntscr.com/xb40i1
https://github.com/maddinat0r/samp-tsconnector/releases


  Divide by zero
Posted by: Zow - 2021-01-20, 06:02 PM - Forum: Pawn Scripting - Replies (1)

Code:
ExpProgress(playerid)

{

? ? new Float:exp = playerData[playerid][pExp]*100/PlayerRequiredExp(playerid);

? ? return exp;

}



PlayerRequiredExp(playerid)

{

? ? new requiredexp = playerData[playerid][pLevel] * 2000;

return requiredexp;

}



pExp are always start from 0 when you're level up

So crashdetect always give me this?Run time error 11: "Divide by zero"

I need some idea how to get pass this one

I just want to popup exp to % but I need pExp to start by 0 when level up

Is that possible?


  How much cpu & ram requirement for sa-mp server?
Posted by: LinesinRows - 2021-01-20, 01:33 PM - Forum: Support - No Replies

? Hello,

?I'm making a rp mod from 0. A few months later, i will be open my server. But i don't know, how much cpu & ram requirement?for?sa-mp server? (etc: 500 players)

? Thanks for now.


  Why my code only sends "else"?
Posted by: sampaux - 2021-01-20, 12:50 PM - Forum: Pawn Scripting - Replies (1)

Code:
for(new i = 0;i < 100;i)

{

if(PlayerInfo[i][cargo] != 0)

{

? ? GameTextForPlayer(i, "~r~Novo Report!", 3000, 5);

? ? GetPlayerName(id, reportado, sizeof(reportado));

? ? GetPlayerName(playerid, reportador, sizeof(reportador));

? ? format(report, sizeof(report), "Nick e id: %s [%d]\nMotivo: %s\nReportado por: %s", reportado, id, motivo, reportador);

? ? SendClientMessage(i, -1, "====={4291ff}Novo Report{FFFFFF}=====");

? ? SendClientMessage(i, -1, report);

}

else

{

SendClientMessage(i, -1, "asdadsadad");//I put it?in else?to prove that code only sends else

}



this code is a /report command. PlayerInfo[][cargo] == Admin level

despite my PlayerInfo[][cargo] != 0 in?game, this code keep sending the else,? considering?PlayerInfo[][cargo] == 0

Basically, it sends "?SendClientMessage(i, -1, "asdadsadad"); " for all online admins instead of the fist code,?and this is not what should happen



Fix it?is easy, obviously just invert?the codes.?But i want know WHY THIS OCCURS???


  Tutorials
Posted by: RhaegarX - 2021-01-20, 11:33 AM - Forum: General Discussions - Replies (2)

Hi guys, I was browsing the pages of sampforumarchiv reviewing some topics, and then I thought about re-posting some tutorials and includes the old samp forum (with due credit to each creator) to be able to move the community more and help those who are new and there's nowhere to go. What do you think of the idea?


  ??????? ?? ?????? ???. ???????
Posted by: Silicium - 2021-01-20, 08:45 AM - Forum: Russian/??????? - Replies (1)

???????????.

??? ??? ????? ????? ????? ?????, ? ????? burgershot'a ????????? ? open.mp, ??????? ? ???? ??????? ???? ??? ?????? ??????? sa:mp, ?? ???? ???? ???????? ?? ?????? ???????? ???. ???????:

????? ?? ???-????? ??? ???????? ????? ?? ?????? ?-?? "????????? ???????"???? ???????????



P.s. ?????? ??????? ??? ?????? "???????" ?????. ??, ????? ?????, ????? ?? ??? ???? ?????? ?????????.


  [MAP] PUB Interior | Mirsat24
Posted by: mirsat24 - 2021-01-20, 06:12 AM - Forum: Videos and Screenshots - Replies (3)

Discord:Mirsat24#8134



If you comment, you will make me happy :)



[Video: http://https://www.youtube.com/watch?v=J7DmeBKX4_w]


  Factions
Posted by: Jaua - 2021-01-20, 01:07 AM - Forum: Pawn Scripting - Replies (5)

.....


Information [Help] - Park vehicle cmd issues
Posted by: Disretired - 2021-01-20, 12:15 AM - Forum: Pawn Scripting - Replies (4)

Hello all, myself and a group of friends are working on a server and have noticed an issue with our park vehicle command.



The command only parks the car in Virtual World 0, we wanted to do dynamic garages, but when we /park in a garage with another VW other then 0 the car disappears and is parked in the VW 0 instead of the VW the garage is set too.



I've attached the command below if anyone can point out the issue, this is the command we had when we first started the project, I myself am still getting the hang of pawn so not sure what the problem is that's causing it to only park in VW 0.



Code:
CMD:park(playerid, params[])

{

if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2 || PlayerInfo[playerid][pDonateRank] == 5)

{

new playerpark;

if(!sscanf(params, "i", playerpark))

{

for(new d = 0; d < MAX_PLAYERVEHICLES; d)

{

if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerpark][d][pvId]))

{

new Float:x, Float:y, Float:z, Float:angle, Float:health;

GetVehicleHealth(PlayerVehicleInfo[playerpark][d][pvId], health);

if(PlayerInfo[playerpark][pLockCar] == GetPlayerVehicleID(playerid)) PlayerInfo[playerpark][pLockCar] = INVALID_VEHICLE_ID;

GetVehiclePos(PlayerVehicleInfo[playerpark][d][pvId], x, y, z);

GetVehicleZAngle(PlayerVehicleInfo[playerpark][d][pvId], angle);

SurfingCheck(GetPlayerVehicleID(playerid));

UpdatePlayerVehicleParkPosition(playerpark, d, x, y, z, angle, health);

PutPlayerInVehicle(playerid, PlayerVehicleInfo[playerpark][d][pvId], 0);

SetPlayerArmedWeapon(playerid, 0);

new string[30  (MAX_PLAYER_NAME * 2)];

format(string, sizeof(string), "* %s has parked %s's vehicle for them.", GetPlayerNameEx(playerid), GetPlayerNameEx(playerpark));

new szMessage[128];

format(szMessage, sizeof(szMessage), "AdmCmd: %s has parked %s's vehicle for them", GetPlayerNameEx(playerid), GetPlayerNameEx(playerpark));

ABroadCast(COLOR_LIGHTRED,szMessage, 2);

ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

return 1;

}

}

SendClientMessageEx(playerid, COLOR_GRAD1, "You need to be in a player owned vehicle");

}

else

SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /park <playerid>");

}

else

SendClientMessageEx(playerid, COLOR_GRAD1, "Park is now an moderator command to combat abuse. /requesthelp or /am to an admin to get a car parked at your house.");

return 1;

}