Quote:
Originally Posted by Raelyn
Awesome.
Another thing, I was under the impression that variable type is automatically detected, but it seems like setting a variable to a string of text doesn't work?
Trying to do something like this:
PHP Code:
clientr.weapon_img = weaponname.png;
if (trigger){
showimg index,clientr.weapon_img,,,;
}
|
Use:
PHP Code:
clientr.weapon_img = "weaponname.png";
for strings
Quote:
Also, I tried using:
PHP Code:
function onKeyPressed(code, key, char) {
if (key == "p") {
temp.img = findImg(200);
img.visible = ! img.visible;
}
}
Not sure how to implement this, as a function, isn't it redundant to do this?:
PHP Code:
if (keypressed){
onKeyPressed(,p,);
}
|
onKeyPressed is called on default. Basically all of the event
if's were converted to "function onEvent", such as "onPlayerTouchsMe", "onCreated", and "onPlayerEnters". There's no need for the if (keypressed) statement.
Quote:
Hrrm, am I doing this properly?
Doesn't this work?
PHP Code:
showimg 200,imagename.png,,,;
hideimg 200;
if (keypressed) {
if (strequals(#p(1),p)) {
temp.img = findImg(200);
img.visible = ! img.visible;
}
}
|
hideimg might be actually destroying the image (actually, I'm pretty sure it does). Just hide it with findImg().visible. And, I don't think showimg has that many paramaters.
Plus.... you're combining GS1 and GS2 in a horrible way
Quote:
Originally Posted by Raelyn
Ugh, I don't know how else to do this.
I want the weapon icon to be displayed dependant on the type of weapon equipped, so..
PHP Code:
if (clientr.weapon = 0001;){
clientr.weapon_img = weaponicon.png;
}
showimg index, clientr.weapon_img,,,;
|
Something like this I guess...
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.wep_type.sword = "sword.png";
}
function displayImage() {
showimg(200, getImageForType(clientr.weaponType), 0, 0);
}
function getImageForType(wep) {
return this.wep_type.(@ wep);
}
and just set clientr.weaponType or another variable when you change the player's weapon. Also, there's really no reason to use clientr. for a weapon image.
And, I'm pretty sure you're adding an extra parameter to showimg almost everywhere. Press F2 and click on "Scripts", it may be giving an error.