Raised This Month: $ Target: $400
 0% 

Saving in arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 10-22-2010 , 06:50   Saving in arrays
Reply With Quote #1

Is it possible to save a text message in arrays like:

PHP Code:
new something "" 
then in some commands add something like this:

PHP Code:
something "hi you are an idiot" 
or
PHP Code:
something "hi you are an dumbass" 
then show that in menu:

PHP Code:
formatex(title511"message of the hour:^n\y ^"%s^"^n\w."something
and also: display a message to player:
PHP Code:
client_print(idprint_chat"moth: ^"%s^", something) 
reinert is offline
Schwabba
Senior Member
Join Date: Apr 2008
Old 10-22-2010 , 07:24   Re: Saving in arrays
Reply With Quote #2

failpost xD

Last edited by Schwabba; 11-21-2010 at 19:29.
Schwabba is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 10-22-2010 , 07:57   Re: Saving in arrays
Reply With Quote #3

what for I need array "i" ?

maybe could explain me more ?

why not just

something[] = "blabla" or something = "blabla"
reinert is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-22-2010 , 08:00   Re: Saving in arrays
Reply With Quote #4

You can declare a string like that : new something[] = "hi you are an idiot" ;

But if you string is already declared somewhere, you can't copy text directly, you need to use copy().
__________________
Arkshine is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 10-22-2010 , 08:19   Re: Saving in arrays
Reply With Quote #5

So how can I change my something result from "hi you are an idiot" to "hi you are a dumbass"


new reason[] = "";
reinert is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-22-2010 , 08:25   Re: Saving in arrays
Reply With Quote #6

use copy().

new reason[] = ""; <== If you declare a variable without string, you need to specify the max length. new reason[ 128 ]; for example.

There are already severals tutorials about such basic knowledge. Start to read that.

http://forums.alliedmods.net/showthread.php?t=94381
http://forums.alliedmods.net/showthread.php?t=91207
__________________
Arkshine is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-22-2010 , 13:51   Re: Saving in arrays
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
But if you string is already declared somewhere, you can't copy text directly, you need to use copy().
You can, as long as the other string has the same number of elements.
PHP Code:
new g_szString1[] = "txt1"// 5 elements
new g_szString2[5]; // Or sizeof(g_szString1)
 
g_szString2 g_szString1;
g_szString1 "txt2"
__________________

Last edited by hleV; 10-22-2010 at 13:54.
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-22-2010 , 18:24   Re: Saving in arrays
Reply With Quote #8

Quote:
Originally Posted by hleV View Post
You can, as long as the other string has the same number of elements.
PHP Code:
new g_szString1[] = "txt1"// 5 elements
new g_szString2[5]; // Or sizeof(g_szString1)
 
g_szString2 g_szString1;
g_szString1 "txt2"
But, not recommended at any time.
__________________
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-22-2010 , 18:34   Re: Saving in arrays
Reply With Quote #9

@hleV ; You don't need to say that to me, but I don't see how it can be useful to a beginner, like said fysiks that's not recommended and it would have been confusing for him. He will discover that naturally after having more knowledge.
__________________
Arkshine is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 10-23-2010 , 03:53   Re: Saving in arrays
Reply With Quote #10

By the way, I wan't to ask, if I use menu with player list in it. When one admin selects for example player1, then there is another menu, what do you want to do with him... And at the same time another admin selects player2... I'm saving players like new tempid; So when first admin chooses an action Does action will be applied to Player1 what he selected, or player2 which was selected last and saved in tempid array.
reinert is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode