var_for_name() ??? execute();???

Posted By: PrenceOfDarkness

var_for_name() ??? execute();??? - 01/14/08 07:33

Okay, i'm working on a multiplayer game. I want to send a string for the players to execute on the local computers. The problem isn't that they aren't recieving the string, instead, the problem seems to be execute();. It simply just wont work. So I read the manual, and var_for_name() I'm guessing should be used instead when you want to change a variable. Well... it just doesn't seem to work. Do they not work in C-lite? Or is it a logic error/syntax error on my end?
Posted By: PrenceOfDarkness

Re: var_for_name() ??? execute();??? - 01/14/08 08:00

sorry for wasting your time guys... Incase anyone else had this problem, all you need to do is change any STRING* name = ""; to STRING* name "#n"; where n = how big you need the string to be... THIS MAKES MY LIFE 10X EASIER!
Posted By: Tor

Re: var_for_name() ??? execute();??? - 01/14/08 09:32

when you initialize the string to "" you're basically initializing the length of the array (a string is an array of char's) to 0, which means that it most likely wont fit anything in it.

I can't remember (haven't used liteC in a while) so it's probably best to just leave it as:

Code:

STRING* name;



until you are ready to add stuff to it or something.
Posted By: PrenceOfDarkness

Re: var_for_name() ??? execute();??? - 01/15/08 08:35

okay for some reason this works:

STRING* zoneSkillExeStr = "#20";

Code:

str_cat(zoneSkillExeStr,"my.z=1000;");
var_for_name(zoneSkillExeStr);



and this doesn't:
Code:

str_cat(zoneSkillExeStr,"my.skill30=5;");
var_for_name(zoneSkillExeStr);



I've read the manual... it says when there is an equal sign use var_for_name instead of execute... but i even tried:
Code:

str_cat(zoneSkillExeStr,"my.z=1000;");
execute(zoneSkillExeStr);



I hate strings... Anyone have any clue to what the heck is going on? I don't see any logic errors but i'm sure they are there...
Posted By: yorisimo

Re: var_for_name() ??? execute();??? - 01/15/08 14:42

try using str_cpy first, then adding to the string with str_cat
© 2024 lite-C Forums