Re: Little coding questions - For general minor queries 5 -
Jeroen52 - 07.03.2017
Quote:
Originally Posted by Dayrion
Is it possible to make a function with an arg which accept 2 type like string & integer ?
|
Do you mean something like use the same arg for both string and integer, or integer and string?
PHP код:
example(int, string[])
{
return 1;
}
Or this?
PHP код:
example(string[])
{
if(!strval(string))
print("Arg is a string.");
else
print("Arg is an integer");
return 1;
}
Re: Little coding questions - For general minor queries 5 -
Dayrion - 07.03.2017
Quote:
Originally Posted by Jeroen52
Do you mean something like use the same arg for both string and integer, or integer and string?
PHP код:
example(int, string[])
{
return 1;
}
Or this?
PHP код:
example(string[])
{
if(!strval(string))
print("Arg is a string.");
else
print("Arg is an integer");
return 1;
}
|
The same arg with two types like Function(code[]/Float:code) and you can use 'code' as a Float and a string.
Re: Little coding questions - For general minor queries 5 -
AvicennaRabama - 08.03.2017
I can't give the detail, what's happened on my gamemode. First, I register to the server. Then, it's all ready done. I logged in. Successfully, all worked. I try to reconnect, then I login. It's done, successfully. The second try, I login. After login, I alt-tab then I GMX my server from the VPS. After that, I got "Server Closed Connection" as always because I did GMX.
After GMX, I re-connecting again. Then I got "Incorrect Password" after that. But I'm sure, I'm not fill the wrong password because my password is just "123456". I dont know what's happened, and what's wrong on my server. I used DINI, because i'm newbie then I have to learn about saving system and others. The DINI is very simple and recommended for beginner scripter.
Re: Little coding questions - For general minor queries 5 -
Logic_ - 09.03.2017
I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?
PHP код:
new aID = 5; // holds the alphabet ID;
printf("%c is where the bomb is.", GetAlphabet(aID));
So this'll print 'F' as letter F is 5, letter A is 1 and letter Z = 25.
---
I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
Re: Little coding questions - For general minor queries 5 -
denNorske - 09.03.2017
Quote:
Originally Posted by Logic_
I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?
PHP код:
new aID = random(25 - 1) + 1; // holds the alphabet ID;
printf("%s is where the bomb is.", GetAlphabet(aID));
---
I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
|
I'm not quite familiar what you put in "alphabet" id's - could you try explain what it should, because i didn't get it
Re: Little coding questions - For general minor queries 5 -
Threshold - 09.03.2017
Quote:
Originally Posted by Logic_
I'm trying to fetch alphabets according to their IDs and I know it's possible but how can I do that? is there something that I can use?
PHP код:
new aID = 5; // holds the alphabet ID;
printf("%c is where the bomb is.", GetAlphabet(aID));
So this'll print 'F' as letter F is 5, letter A is 1 and letter Z = 25.
---
I've a object which moves under some specific conditions and it's in the sky but it falls and comes to the ground and/ or destroys. What's must be causing it? Any guesses?
|
http://www.asciitable.com/
Each character has a numerical value.
string[0] = 'F' would be the same as doing string[0] = 70, however lowercase and uppercase letters have different values.
So theoretically:
PHP код:
GetAlphabet(alphaid, uppercase = false)
return (uppercase) ? (alphaid + 65) : (alphaid + 97);
Код:
printf("%c %c %c %c", GetAlphabet(6), GetAlphabet(6, .uppercase = true), GetAlphabet(22), GetAlphabet(22, true));
Would print:
And F would be the 6th letter of the alphabet, not 5th. This function starts at index '0', where 'A' is 0, 'B' is 1, etc. If you want to change this so A is index 1, all you need to do is replace '+ 65' and '+ 97' with '+ 64' and '+ 96'.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 09.03.2017
This is not possible?
PHP код:
InfoOOC(const playerid, message[], va_args<>)
return Info(playerid, INFO_OOC, _, message, va_args);
Re: Little coding questions - For general minor queries 5 -
AjaxM - 10.03.2017
Try to figure how to fix this since 1 month.
Issue:
Enum datas are getting mixed up together or simply assigning random values.
Examples:
- Password variable mixing up with Zone[100] variables. Thus, from debugging, i found out why the password weren't matching. Found out that it was setting the password typed to "Blueberry Acres".
- readcmds value auto-sets to true when a player logs.
What i tried to fix the issue:
- Resetting all the variables when the player logs in/out.
- Used a seperate enums for other datas (E_PLAYERDATA enum for basic vars and E_OtherInfos for other infos for decreasing the variables on E_PLAYERDATA)
__________________________________________________ _______________________________________________
Nothing worked, i thank you in advance if you found a fix for it. Code is below!
PHP код:
enum E_PLAYERDATA
{
ID,
Password[65],
Salt[15],
VIP,
Kills,
Deaths,
aDate,
bool:UnderCover = false,
bool:readcmds = false,
bool:readpms = false,
Zone[100],
LoggedIn,
BankCash,
BribesAccepted
};
new pInfo[MAX_PLAYERS][E_PLAYERDATA];
Re: Little coding questions - For general minor queries 5 -
AjaxM - 10.03.2017
Quote:
Originally Posted by [HLF]Southclaw
Sounds like memory corruption, what includes and plugins do you use?
|
I use these:
PHP код:
#include <a_samp>
#include <i-zcmd>
#include <sscanf2>
#include <a_mysql>
#include <foreach>
#include <streamer>
#include <line>
Re: Little coding questions - For general minor queries 5 -
DutchBoy - 11.03.2017
how can i add more then 1 object id to
Код:
if(IsValidObject(objectid))
also is it possible to add the specif pos for the object in IsObjectValid and DestroyObject?? so that it only destroys that object and not one whit the same id on the other side of the map?
Thanks in advance
pm me if you need need more info on the script
Re: Little coding questions - For general minor queries 5 -
khRamin78 - 10.04.2017
Quote:
Originally Posted by noPANDA
difference between
if(somethinghere)
and
if(!somethinghere)?
|
if(something)
used for a bool var (and also null intr)and if something is true it will be called
and !something is false
so :
they are same like
if(somethinghere) => if(somethinghere == true)
&
if(!somethinghere) => if(!somethinghere == false)
Re: Little coding questions - For general minor queries 5 -
Jeroen52 - 10.04.2017
Quote:
Originally Posted by noPANDA
difference between
if(somethinghere)
and
if(!somethinghere)?
|
PHP код:
if(somethinghere) //If the value is true
PHP код:
if(!somethinghere) //If the value is false
Re: Little coding questions - For general minor queries 5 -
khRamin78 - 11.04.2017
guys i know its basic one but i realy want to know
is any different between null and 0 ?
Re: Little coding questions - For general minor queries 5 -
khRamin78 - 11.04.2017
Quote:
Originally Posted by Gamer_Z
Depends on the language..
|
i mean if it is possible to check if is a varb null(with out any data defined) or 0
Re: Little coding questions - For general minor queries 5 -
khRamin78 - 12.04.2017
Quote:
Originally Posted by [HLF]Southclaw
There's no such thing in Pawn. All variables are 32 bits wide and have a default value of 0. There are also no pointers in Pawn so there's no need for a null value.
|
aha thanks
Re: Little coding questions - For general minor queries 5 -
Logic_ - 15.04.2017
Removed.
Re: Little coding questions - For general minor queries 5 -
GaByM - 20.04.2017
What's better: every player with his timer or a single timer with a loop inside?
Re: Little coding questions - For general minor queries 5 -
Logic_ - 20.04.2017
Quote:
Originally Posted by GaByM
What's better: every player with his timer or a single timer with a loop inside?
|
Per-player timers, but they can be spammed through hacks.
Re: Little coding questions - For general minor queries 5 -
GaByM - 20.04.2017
Quote:
Originally Posted by Logic_
but they can be spammed through hacks.
|
What do you mean?
Re: Little coding questions - For general minor queries 5 -
Jeroen52 - 20.04.2017
Quote:
Originally Posted by Logic_
Per-player timers, but they can be spammed through hacks.
|
https://sampwiki.blast.hk/wiki/SetTimer
- Timer intervals are not accurate (roughly 25% off). There are fixes available here and here.
- Timer IDs are never used twice. You can use KillTimer() on a timer ID and it won't matter if it's running or not.
- The function that should be called, must be public, meaning it has to be forwarded.
- The use of many timers will result in increased memory/cpu usage.
Wasn't using more efficient to use a single timer with a loop inside?
Besides, Pawn is single-threaded anyways so the timers don't run on a separate thread.