AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Array (https://forums.alliedmods.net/showthread.php?t=293455)

ambn 02-01-2017 08:16

Array
 
hi, i'm making a simple plugin and i have a small problem , i kinda don't know how to make it work,
i'm trying to assign a string to an array and i've googled but found nothing of use ,
PHP Code:

PlayerArmPath[param1] = ArmPath;
PlayerSkinPath[param1] = SkinPath

i've got ArmPath and SkinPath from a keyvalue file via KvGetString and stored it into Those Strings (ArmsPath & SkinPath) , but when i do what i did , i get compile errors , how can i make it work?
NOTE : PlayerSkinPath[param1] and the other string are global , per player strings ,
i might look like a noob but can someone please help me make it work?

Addicted. 02-01-2017 08:32

Re: Array
 
PHP Code:

StrCopy(char[] destint destLen, const char[] source

https://sm.alliedmods.net/new-api/string/strcopy

Kailo 02-01-2017 08:36

Re: Array
 
You can do like
PHP Code:

PlayerArmPath[param1] = ArmPath;
PlayerSkinPath[param1] = SkinPath

Then PlayerArmPath[] and ArmPath have equal size else use strcopy.

ambn 02-01-2017 09:26

Re: Array
 
so then it would be like this?
Quote:

StrCopy(PlayerArmPath, sizeof(PlayerArmPath), ArmPath);
StrCopy(PlayerSkinPath, sizeof(PlayerSkinPath), SkinPath);
but it does not make sense , i'm trying to set parma1 String to something but does sizeof does it? i'm not sure if it do ...

Michael Shoe Maker 02-01-2017 09:43

Re: Array
 
Quote:

Originally Posted by ambn (Post 2491809)
so then it would be like this?

but it does not make sense , i'm trying to set parma1 String to something but does sizeof does it? i'm not sure if it do ...

StrCopy(PlayerArmPath[param1], sizeof(PlayerArmPath[]), ArmPath);
StrCopy(PlayerSkinPath[param1], sizeof(PlayerSkinPath[]), SkinPath);

ambn 02-01-2017 09:59

Re: Array
 
Quote:

Originally Posted by Michael Shoe Maker (Post 2491816)
StrCopy(PlayerArmPath[param1], sizeof(PlayerArmPath[]), ArmPath);
StrCopy(PlayerSkinPath[param1], sizeof(PlayerSkinPath[]), SkinPath);

I tryed
PHP Code:

PrintToChatAll("%s skin %s arm"PlayerSkinPath[client], PlayerArmPath[client]); 

and it returned NULL after using this ,
what now?

Michael Shoe Maker 02-01-2017 10:34

Re: Array
 
Quote:

Originally Posted by ambn (Post 2491823)
I tryed
PHP Code:

PrintToChatAll("%s skin %s arm"PlayerSkinPath[client], PlayerArmPath[client]); 

and it returned NULL after using this ,
what now?

How have you defined PlayerArmPath

ambn 02-01-2017 10:40

Re: Array
 
Quote:

Originally Posted by Michael Shoe Maker (Post 2491830)
How have you defined PlayerArmPath

It's a Global String Like This:
PHP Code:

new String:PlayerSkinPath[MAXPLAYERS 1]; 


Kolapsicle 02-01-2017 10:52

Re: Array
 
You're creating a string with the size of MAXPLAYERS so I'm going to assume you want a string per client?

PHP Code:

char PlayerSkinPath[MAXPLAYERS 1][64];
Format(PlayerSkinPath[client], sizeof(PlayerSkinPath[]), SkinPath); 


ambn 02-01-2017 10:58

Re: Array
 
Quote:

Originally Posted by Kolapsicle (Post 2491839)
You're creating a string with the size of MAXPLAYERS so I'm going to assume you want a string per client?

PHP Code:

char PlayerSkinPath[MAXPLAYERS 1][64];
Format(PlayerSkinPath[client], sizeof(PlayerSkinPath[]), SkinPath); 


ok , let me test it and i'll let you know if it works.


All times are GMT -4. The time now is 21:03.

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