SA-MP Forums Archive
WTF?! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: WTF?! (/showthread.php?tid=582799)



WTF?! - Lirbo - 23.07.2015

PHP код:
CMD:test(playerid,params[]){
new 
HourSecondMinuteDayMonthYear;
gettime(Hour,Second,Minute);
getdate(DayMonthYear);
format(Stringsizeof(String),"Time: %i:%i:%i | Date: %i/%i/%i",Hour,Minute,Second,Day,Month,Year);
MSG(playerid,C_RED,String);
return 
1;} 
such as simple cmd and so many errors etc, never happened to me before

PHP код:
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Hour" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Second" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Minute" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Day" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Month" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 219local variable "Year" shadows a variable at a preceding level
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(813) : error 035argument type mismatch (argument 1)
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(814) : error 035argument type mismatch (argument 1)
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(815) : warning 213tag mismatch
C
:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 203symbol is never used"Year"
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 203symbol is never used"Month"
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 203symbol is never used"Day"
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 203symbol is never used"Minute"
C:\Users\Lirbo\Desktop\GRRP\gamemodes\Register.pwn(812) : warning 203symbol is never used"Second" 



Re: WTF?! - Gazzy - 23.07.2015

In your script, instead of %i use %02d. Also, you have not made a new string, so add String[256]; to new.


Re: WTF?! - liquor - 23.07.2015

Код:
warning 219: local variable "Year" shadows a variable at a preceding level
This means that you have created a global array or integer named "Year".
The command compiles fine in my script (after changing MSG to SendClientMessage, and C_RED to a color I have defined in my script).

Try removing that line:
pawn Код:
CMD:test(playerid,params[]){
gettime(Hour,Second,Minute);
getdate(Day, Month, Year);
format(String, sizeof(String),"Time: %i:%i:%i | Date: %i/%i/%i",Hour,Minute,Second,Day,Month,Year);
MSG(playerid,C_RED,String);
return 1;}



AW: WTF?! - Mencent - 23.07.2015

Hello!

Try this:
PHP код:
CMD:test(playerid,params[])
{
    new 
Hour2,Second2,Minute2,Day2,Month2,Year2,String[145];
    
gettime(Hour2,Second2,Minute2);
    
getdate(Day2,Month2,Year2);
    
format(String,sizeof String,"Time: %i:%i:%i | Date: %02d/%02d/%i",Hour2,Minute2,Second2,Day2,Month2,Year2);
    
MSG(playerid,C_RED,String);
    return 
1;

- Mencent


Re: WTF?! - liquor - 23.07.2015

Quote:
Originally Posted by Gazzy
Посмотреть сообщение
In your script, instead of %i use %02d. Also, you have not made a new string, so add String[256]; to new.
There's nothing wrong with %i, %02d is NOT what he's currently trying to do. %02d just means "add a zero if integer is less than 10." (1 = 01 etc.)

And he probably have created a GLOBAL array called "String", and the size 256 is DOUBLE the size of what is possible to send to a client, so it is very stupid.


Re: WTF?! - Crystallize - 23.07.2015

Quote:
Originally Posted by Gazzy
Посмотреть сообщение
In your script, instead of %i use %02d. Also, you have not made a new string, so add String[256]; to new.
Unless you want to waste your memory use it...
That's very bad advice , why using 256 instead of less + he's not sending a big message , it's just waste of kilobytes


Re: WTF?! - Gazzy - 23.07.2015

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Unless you want to waste your memory use it...
That's very bad advice , why using 256 instead of less + he's not sending a big message , it's just waste of kilobytes
Sorry I'm not a pro scripter lol


Re: WTF?! - Overhaul - 23.07.2015

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Unless you want to waste your memory use it...
That's very bad advice , why using 256 instead of less + he's not sending a big message , it's just waste of kilobytes
256 bits = 32 bytes to be exact, which is 0.032 kilobytes. It's not a lot. Though, it's something you can easily avoid and should avoid.


Re: AW: WTF?! - Lirbo - 23.07.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Try this:
PHP код:
CMD:test(playerid,params[])
{
    new 
Hour2,Second2,Minute2,Day2,Month2,Year2,String[145];
    
gettime(Hour2,Second2,Minute2);
    
getdate(Day2,Month2,Year2);
    
format(String,sizeof String,"Time: %i:%i:%i | Date: %02d/%02d/%i",Hour2,Minute2,Second2,Day2,Month2,Year2);
    
MSG(playerid,C_RED,String);
    return 
1;

- Mencent
<3 thanks bro, It's working, but I already had the String defined in the top of the script
You got +Rep from me


Re: WTF?! - Crystallize - 23.07.2015

Quote:
Originally Posted by Overhaul
Посмотреть сообщение
256 bits = 32 bytes to be exact, which is 0.032 kilobytes. It's not a lot. Though, it's something you can easily avoid and should avoid.
It's not a lot but it's a good practice to avoid using a lot of it as I said unless you want to waste your VPS's memory